2

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?

7
  • In ReactDOMNullInputValuePropDevtool.js do you have import '\\users\home\smeghani\private\codebase\react-demo\node_modules\process\browser.js'? Commented Aug 4, 2016 at 10:21
  • No. ReactDOMNullInputValuePropDevtool.js is not my custom file. It is included as one of the node dependency (react-dom). So it does not have an import with hard coded path. Commented Aug 4, 2016 at 10:51
  • Sorry about that, I'll delete my answer. I did look through the react code in github and apparently that file was just renamed to ReactDOMNullInputValuePropHook.js, and it doesn't seem to be importing process, so you could try an update. Commented Aug 4, 2016 at 11:54
  • Actually, this is just one example of error. I get the same error for any plugins I use. So it mostly seems, I am missing some configuration in webpack.config.js on how plugin dependencies should be resolved. I tried with resolve and resolveLoaders without any luck. Commented Aug 4, 2016 at 12:17
  • Can you post what your webpack config is regarding resolve and resolveLoaders is right now or were you setting those propertys when you got those errors? Commented Aug 4, 2016 at 13:32

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.