react-boilerplate: Module not found: Error: Can't resolve 'fs'

Module not found: Error: Can’t resolve ‘fs’ in ‘/Users/js/code/react/react-boilerplate/node_modules/shelljs/src’

Issue Type

Description

I’ve used this boilerplate successfully in the past. First I tried it with yarn installed. Then, I uninstalled yarn and tried again. Same error both times.

Building the Webpack DLL...
Hash: f64cd94e521a0c2f99ea
Version: webpack 2.1.0-beta.25
Time: 4360ms
                      Asset     Size  Chunks             Chunk Names
reactBoilerplateDeps.dll.js  3.32 MB       0  [emitted]  reactBoilerplateDeps
chunk    {0} reactBoilerplateDeps.dll.js (reactBoilerplateDeps) 2.79 MB [entry] [rendered]
    [2] dll reactBoilerplateDeps 12 bytes {0} [built]
     + 736 hidden modules

ERROR in ./~/shelljs/src/common.js
Module not found: Error: Can't resolve 'fs' in '/Users/js/code/react/react-boilerplate/node_modules/shelljs/src'
 @ ./~/shelljs/src/common.js 6:9-22
 @ ./~/shelljs/shell.js
 @ dll reactBoilerplateDeps

ERROR in ./~/shelljs/src/cd.js
Module not found: Error: Can't resolve 'fs' in '/Users/js/code/react/react-boilerplate/node_modules/shelljs/src'
 @ ./~/shelljs/src/cd.js 1:9-22
 @ ./~/shelljs/shell.js
 @ dll reactBoilerplateDeps

ERROR in ./~/shelljs/src/ls.js
Module not found: Error: Can't resolve 'fs' in '/Users/js/code/react/react-boilerplate/node_modules/shelljs/src'
 @ ./~/shelljs/src/ls.js 2:9-22
 @ ./~/shelljs/shell.js
 @ dll reactBoilerplateDeps
(truncated)

Steps to reproduce

git clone --depth=1 https://github.com/mxstbr/react-boilerplate.git
npm run setup

Versions

  • Node/NPM:
$ yarn --version
0.17.9
$ npm --version
3.10.9
$ node --version
v7.2.0
  • Browser: NA

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 11
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I just had the same problem from a fresh clone of the repo.

I had to add this to the “webpack.base.babel.js” config:

node: {
    fs: 'empty',
    child_process: 'empty',
  },

I found the workaround here: https://github.com/webpack-contrib/css-loader/issues/447

I found the error for myself at least, the docs didn’t state all that well. You just need to add the conflicting package to dllPlugin.exclude: [] in your package.json file.

One of the things that can cause this bug is adding packages to the wrong dependency section. For instance yarn add gulp will add it to dependencies instead of devDependencies.

I ended up trying @sebelga 's solution, but it still didn’t work – I found another suggestion on a different GH issue and this is what ended up working for me.

In your webpack.config.*.js file, add the following to plugins after new webpack.DllPlugin({}):

new webpack.IgnorePlugin(/your_package_name_here/). For me, it was yarn that was blowing stuff up.

Hope this helps!

Thanks @coleclayman! I had no luck with what seemed like an endless stream of other suggested fixes but your approach worked for me (in my case it was a host of packages but |ing them all in the RE in IgnorePlugin was the fix: new webpack.IgnorePlugin(/fs|tls|net|child_process|term.js|pty.js|readline|dgram|dns|repl|\.\.\/API\/schema/)

Hi, I am using react-boilerplate v3.3.3 with Node v6.9.2 with npm v3.10.9.

I added a new dependency (Raven v1.1.1) and when I run npm run build:dll facing the same Error.

Here is the stack error:

` Building the Webpack DLL… Hash: da2f8f7db2b0a2adbac2 Version: webpack 2.1.0-beta.25 Time: 7106ms Asset Size Chunks Chunk Names reactBoilerplateDeps.dll.js 4.04 MB 0 [emitted] reactBoilerplateDeps chunk {0} reactBoilerplateDeps.dll.js (reactBoilerplateDeps) 3.48 MB [entry] [rendered] [6] dll reactBoilerplateDeps 12 bytes {0} [built] + 875 hidden modules

ERROR in ./~/raven/lib/utils.js Module not found: Error: Can’t resolve ‘fs’ in ‘/Users//Documents/workspace//web_app/node_modules/raven/lib’ @ ./~/raven/lib/utils.js 3:9-22 @ ./~/raven/index.js @ dll reactBoilerplateDeps

ERROR in ./~/raven/lib/breadcrumbs.js Module not found: Error: Can’t resolve ‘pg’ in ‘/Users//Documents/workspace//web_app/node_modules/raven/lib’ @ ./~/raven/lib/breadcrumbs.js 132:13-26 @ ./~/raven/lib/client.js @ ./~/raven/index.js @ dll reactBoilerplateDeps

ERROR in ./~/lsmod/index.js Module not found: Error: Can’t resolve ‘fs’ in ‘/Users//Documents/workspace//web_app/node_modules/lsmod’ @ ./~/lsmod/index.js 2:9-22 @ ./~/raven/lib/utils.js @ ./~/raven/index.js @ dll reactBoilerplateDeps `