4

When I run npm install from a react-boilerplate project several of my 3rd party modules give off errors like you see below. All these modules work fine in other node projects, just not in react-boilerplate. Does anyone know how to fix these?

ERROR in ./~/nconf/lib/nconf.js
Module not found: Error: Can't resolve 'fs' in '/Users/me/src/fullboar/probate-web/node_modules/nconf/lib'
 @ ./~/nconf/lib/nconf.js 8:9-22

ERROR in ./~/nconf/package.json
Module parse failed: /Users/me/src/fullboar/probate-web/node_modules/nconf/package.json Unexpected token (2:9)
You may need an appropriate loader to handle this file type.
| {
|   "_args": [
|     [
|       {
 @ ./~/nconf/lib/nconf.js 21:16-42

ERROR in ./~/nconf/lib/nconf/common.js
Module not found: Error: Can't resolve 'fs' in '/Users/me/src/fullboar/probate-web/node_modules/nconf/lib/nconf'
 @ ./~/nconf/lib/nconf/common.js 8:9-22

ERROR in ./~/sequelize/package.json
Module parse failed: /Users/me/src/fullboar/probate-web/node_modules/sequelize/package.json Unexpected token (2:9)
You may need an appropriate loader to handle this file type.
| {
|   "_args": [
|     [
|       {
 @ ./~/sequelize/lib/sequelize.js 265:20-46
Jason Leach
  • 3,158
  • 4
  • 30
  • 48

1 Answers1

2

I've the same issue on fs package.

ERROR in dll reactBoilerplateDeps
Module not found: Error: Can't resolve 'fs' in '/Users/nico/_dev/crf'
 @ dll reactBoilerplateDeps

To avoid this error I ignore the fs module for browser builds updating the webpack.dll.babel.js file like this:

  // ...
  plugins: [
    new webpack.DllPlugin({ name: '[name]', path: join(outputPath, '[name].json') }), // eslint-disable-line no-new
  ],

  // mock fs
  node: {
    fs: 'empty',
  },
};

I don't know if is the best solution, but for me works fine.

NOTE

Before:

  • I tried to rm -r node_modules && npm cache clean && npm install but the error remained

  • I inserted the fs dependency in the dllPlugin exclude array in internals/config.js file, but the error remained

Documentation

node key in webpack config include polyfills or mocks for various node stuff

NickGnd
  • 4,517
  • 1
  • 16
  • 25