Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Can't resolve 'fs' #1278

Closed
1 of 2 tasks
jshumakerpruitt opened this issue Nov 28, 2016 · 15 comments
Closed
1 of 2 tasks

Module not found: Error: Can't resolve 'fs' #1278

jshumakerpruitt opened this issue Nov 28, 2016 · 15 comments

Comments

@jshumakerpruitt
Copy link

jshumakerpruitt commented Nov 28, 2016

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
@giautm
Copy link

giautm commented Dec 3, 2016

I got same issues:

$ npm --version
3.10.8
$ node --version
v7.0.0

@gihrig
Copy link
Contributor

gihrig commented Dec 3, 2016

How about if you run yarn directly e.g.

rm -rf node_modules
yarn

Or did you do that already?

@sublimeye
Copy link

sublimeye commented Dec 11, 2016

When I run npm run setup I have the same issue. Although both yarn install and npm i finish successfully.

Tried to run yarn install first and then npm run setup but also getting the same error messages from shelljs...

The problem seems like to be in npm run build:dll step.

yarn v0.17.10
node v7.0.0
npm 3.10.8

@gihrig
Copy link
Contributor

gihrig commented Dec 11, 2016

How about after installing with yarn? Can you successfully run:
npm start?

What about
npm run start:production?

The only thing npm run setup gets you over just yarn is a clean git repo, which you can do for yourself. (delete .git and git init)

@sublimeye
Copy link

sublimeye commented Dec 11, 2016

Yes, I'm able to run npm start

The problem seems to lead into webpack.dll build run by:
exec('cross-env BUILDING_DLL=true webpack --display-chunks --color --config internals/webpack/webpack.dll.babel.js');

npm run setup
  postinstall -> npm run build:dll
    -> node ./internals/scripts/dependencies.js
       on line 46 it executes that webpack.dll build .. 

@joshmeads
Copy link

Same issue too while running npm run build:dll. I've also tried deleting node_modules, didn't change it.

Node v7.1.0
Yarn v0.17.10
npm v3.10.9

@joelfsreis
Copy link

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
`

@joshmeads
Copy link

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.

@jshumakerpruitt
Copy link
Author

I re-cloned the repo and no longer get this error. Not sure if it's due to a recent commit or something on my local machine.

@jshumakerpruitt
Copy link
Author

Closing because I can no longer replicate. git clone + yarn works for me now.

@juanibiapina
Copy link

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.

@sebelga
Copy link

sebelga commented Jun 12, 2017

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: webpack-contrib/css-loader#447

johnnyoshika added a commit to johnnyoshika/jellypic-dashboard-from-redux-starter-kit that referenced this issue Oct 11, 2017
Solution from here: react-boilerplate/react-boilerplate#1278. Sort of works but creates graceful-fs exception during runtime.
johnnyoshika added a commit to johnnyoshika/jellypic-dashboard-from-redux-starter-kit that referenced this issue Oct 11, 2017
Solution taken from here: react-boilerplate/react-boilerplate#1278.

Solved on problem and created another. This time with graceful-fs. We get a runtime exception with the error: Uncaught TypeError: Cannot read property 'prototype' of undefined. More info: isaacs/node-graceful-fs#70
richtong pushed a commit to XevoInc/webcamdisplay-react that referenced this issue Oct 19, 2017
johnnyoshika added a commit to johnnyoshika/jellypic-dashboard-from-redux-starter-kit that referenced this issue Jan 27, 2018
Solution taken from here: react-boilerplate/react-boilerplate#1278.

Solved on problem and created another. This time with graceful-fs. We get a runtime exception with the error: Uncaught TypeError: Cannot read property 'prototype' of undefined. More info: isaacs/node-graceful-fs#70
johnnyoshika added a commit to johnnyoshika/jellypic-dashboard-from-redux-starter-kit that referenced this issue Jan 27, 2018
Solution taken from here: react-boilerplate/react-boilerplate#1278.

Solved on problem and created another. This time with graceful-fs. We get a runtime exception with the error: Uncaught TypeError: Cannot read property 'prototype' of undefined. More info: isaacs/node-graceful-fs#70
johnnyoshika added a commit to johnnyoshika/jellypic-dashboard-from-redux-starter-kit that referenced this issue Jan 27, 2018
Solution taken from here: react-boilerplate/react-boilerplate#1278.

Solved on problem and created another. This time with graceful-fs. We get a runtime exception with the error: Uncaught TypeError: Cannot read property 'prototype' of undefined. More info: isaacs/node-graceful-fs#70
@claycoleman
Copy link

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!

@ggprod
Copy link

ggprod commented Mar 31, 2018

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/)

@lock
Copy link

lock bot commented May 28, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests