javascript - Webpack Missing Module 'Module Not Found' -
i'm working on react webpack babel etc site , trying build first time. build successful, when open browser following error:
uncaught error: cannot find module "/users/michael.nakayama/documents/development/jamsesh/node_modules/webpack/node_modules/node-libs-browser/node_modules/process/browser.js"
this module exists. going actual url in browser shows file in question. cannot figure out why webpack cannot find it. don't know if babel6 issue or webpack issue, or neither. config file looks this:
var webpack = require('webpack'); var cleanwebpack = require('clean-webpack-plugin'); var ignore = new webpack.ignoreplugin(new regexp("/(node_modules|ckeditor)/")) module.exports = { devtool: 'inline-source-map', entry: './lib/client/entry', output: { path: __dirname + '/public/js', filename: 'app.js', publicpath: 'http://localhost:8081/js/', }, plugins: [ ignore, ], resolve: { extensions: ['', '.js'], moduledirectories: ['./node_modules'] }, module: { loaders: [ { test: /\.js?$/, loaders: ['babel-loader?presets[]=react,presets[]=es2015,plugins[]=transform-es2015-classes,plugins[]=transform-react-jsx'], exclude: /(node_modules)/, } ] } }
and webpack server file follows:
var webpackdevserver = require('webpack-dev-server'); var webpack = require('webpack'); var config = require('../../webpack.config'); var server = new webpackdevserver(webpack(config), { // webpack-dev-server options publicpath: config.output.publicpath, stats: { colors: true }, }); server.listen(8081, 'localhost', function() {});
and here packages have installed:
"devdependencies": { "babel-cli": "^6.3.17", "babel-core": "^6.3.26", "babel-loader": "^6.2.0", "babel-plugin-syntax-jsx": "^6.3.13", "babel-plugin-transform-es2015-classes": "^6.4.0", "babel-plugin-transform-react-jsx": "^6.3.13", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", "body-parser": "^1.14.2", "clean-webpack-plugin": "^0.1.5", "express": "^4.13.3", "history": "^1.17.0", "jade": "^1.11.0", "nodemon": "^1.8.1", "path": "^0.12.7", "pg": "^4.4.3", "react": "^0.14.6", "react-dom": "^0.14.3", "react-hot-loader": "^1.3.0", "react-router": "^1.0.3", "webpack": "^1.12.9", "webpack-dev-server": "^1.14.0" }
entry.js:
var react = require('react'); var reactdom = require('react-dom'); var reactrouter = require('react-router'); var router = reactrouter.router; var route = reactrouter.route; var routes = require('../routes'); // -v x.13.x /**router.run(routes, router.historylocation, function (handler, state) { react.render(<handler/>, document.getelementbyid('react-app')); });**/ var node = document.getelementbyid('react-app'); // -v 1.0.0 reactdom.render(<router history={createbrowserhistory()} routes={routes}/> , node);
also heads up, have tried uninstalling , reinstalling packages. have tried installing node-libs-browser modules. thanks.
the problem ignore plugin on node_modules
. in webpack.config.js
, have:
var ignore = new webpack.ignoreplugin(new regexp("/(node_modules|ckeditor)/")) ... plugins: [ ignore, ],
from ignore plugin documentation:
don’t generate modules requests matching provided regexp.
webpack tries require
module name node_modules/process/browser
react module , fails because ignored.
try remove node_modules
ignore plugin or write less global condition if need this.
Comments
Post a Comment