Reputation: 905
I am trying out webpack with react. I am trying to use babel-loader to transpile jsx files. I receive module not found error while using any webpack loaders/plugins. I have the required plugins installed in node_modules.
The issue seems to be with the path resolution. Somehow it prepends my current directory to the absolute path while resolving dependent plugins.
Here is my a snippet of my webpack.config.js
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel', // 'babel-loader' is also a legal name to reference
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
}]
}
It gives following error when I run webpack
(globally as well as through npm)
ERROR in ../~/react/lib/ReactDOMNullInputValuePropDevtool.js
Module not found: Error: Cannot resolve module '\\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js' in H:\codebase\react-demo\node_modules\react\lib
resolve module \\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js in H:\codebase\react-demo\node_modules\react\lib
looking for modules in H:\codebase\react-demo\node_modules
resolve 'file' or 'directory' \users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js in H:\codebase\react-demo\node_modules
resolve file
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js doesn't exist
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.webpack.js doesn't exist
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.web.js doesn't exist
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.js doesn't exist
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.json doesn't exist
resolve directory
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js\package.json doesn't exist (directory description file)
H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js doesn't exist (directory default file)
[H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js]
[H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.webpack.js]
[H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.web.js]
[H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.js]
[H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js.json]
@ ../~/react/lib/ReactDOMNullInputValuePropDevtool.js 1:0-102
Here H:\codebase\react-demo\
is my project root directory. I.e node_modules
resides in H:\codebase\react-demo\
. It is trying to look up for dependency in H:\codebase\react-demo\node_modules\users\home\smeghani\private\codebase\react-demo\node_modules
Any idea what am I missing?
Upvotes: 2
Views: 4274
Reputation: 905
I could work-around the issue. Initially, my project directories were on a mapped network drive. Moving the project directory to local drive (C:/) resolved the issue. Still not sure why it was causing the issue though.
Upvotes: 1