Skip to content

"Error: Cannot find module xxx" while it seems to be working fine #5

Description

@TitoVince35

Hello,
Everything seems to be working OK, but I get this error at every build/start:

 module.js:557
     throw err;
    ^
 Error: Cannot find module '/usr/src/app/dist'
     at Function.Module._resolveFilename (module.js:555:15)
     at Function.Module._load (module.js:482:25)
     at Function.Module.runMain (module.js:701:10)
     at startup (bootstrap_node.js:190:16)
    at bootstrap_node.js:662:3

Here is my package.json

"scripts": {
    "dev": "webpack-watch-server --config webpack.dev.xeapi.js"
  },
(...)
  "devDependencies": {
    "babel-loader": "^7.1.4",
    "config-webpack": "^1.0.4",
    "eslint": "^4.19.0",
    "grunt": "^1.0.2",
    "grunt-contrib-clean": "^1.1.0",
    "grunt-env": "^0.4.4",
    "grunt-shell": "^2.1.0",
    "json-loader": "^0.5.7",
    "mocha": "^4.0.1",
    "request": "^2.85.0",
    "request-promise": "^4.2.2",
    "start-server-webpack-plugin": "^2.2.5",
    "webpack": "^4.5.0",
    "webpack-bundle-analyzer": "^2.11.1",
    "webpack-cli": "^2.0.14",
    "webpack-merge": "^4.1.2",
    "webpack-node-externals": "^1.7.2",
    "webpack-watch-server": "^1.2.1"
  }
(...)

Here is webpack.dev.xeapi.js

var path = require('path');
var webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.xeapi.js');
module.exports = merge(common, {
	mode : 'development',
	cache : true,
	stats: {
		// Nice colored output
		colors: true
	},
	// Create Sourcemaps for the bundle
	devtool: 'inline-source-map'
});

...and the required webpack.common.xeapi.js

const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');

module.exports = {
    entry: {
	main: ['./src/index.js']
    },
    output: {
        path: path.join(__dirname,'dist/'),
        filename: 'server-app.js'
    },
    module: {
	    rules: [
	      {
	        test: /\.js$/,
	        use: [{
	          loader: 'babel-loader',
	          options: { presets: ['es2015'] }
	        }],
	      },
	    ],
	  },
  // Keep node_modules out of the generated bundle
  target: 'node',
  externals: [nodeExternals()],
};

Does that ring a bell?

Thanks in advance,

Vince

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions