Cannot find module ‘C:distserver.generated.js’

Solution for Cannot find module ‘C:distserver.generated.js’
is Given Below:

I’m trying to learn how to set up a small web app using node.js, Express, and yarn.

I’ve already used yarn install on the project working directory.
Upon running yarn development I get the following error:

Error: Cannot find module 'C:distserver.generated.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  requireStack: []
[nodemon] app crashed - waiting for file changes before starting...

I don’t understand why it’s looking for server.generated.js in C:dist, as this is something which it autogenerated within the cwd of my project (C:UsersnameDesktopCodingMERNingMERN-Skeleton-Applicationdist) upon running yarn development.

All of my Webpack files specify using the cwd for producing server.generated.js.

const path = require('path')
const nodeExternals = require('webpack-node-externals')
const CURRENT_WORKING_DIR = process.cwd()


const config = {
    name: "server",
    entry: [ path.join(CURRENT_WORKING_DIR , './server/server.js') ],
    target: "node",
    output: {
        path: path.join(CURRENT_WORKING_DIR , '/dist/'),
        filename: "server.generated.js",
        publicPath: '/dist/',
        libraryTarget: "commonjs2"
    externals: [nodeExternals()],
    module: {
        rules: [
                test: /.js$/,
                exclude: /node_modules/,
                use: [ 'babel-loader' ]
                test: /.(ttf|eot|svg|gif|jpg|png)(?[sS]+)?$/,
                use: 'file-loader'

module.exports = config

The problem was that I had a typo in my nodemon.json file.

My code was

    "verbose": false,
    "watch": [ "./server" ],
    "exec": "webpack --mode=development --config webpack.config.server.js && node/dist/server.generated.js"

the correct code would be:

    "verbose": false,
    "watch": [ "./server" ],
    "exec": "webpack --mode=development --config webpack.config.server.js && node ./dist/server.generated.js"

I completely left out the ./ earlier, which explains why it was looking for ‘server.generated.js’ in C: rather than in the current working directory.