0

I have a problem when I run the npm start command. the following errors are displayed:

Compiled with problems:X

ERROR in ./node_modules/cookie-signature/index.js 4:13-30

Module not found: Error: Can't resolve 'crypto' in '/home/mpeubey/Oncobase/front2/node_modules/cookie-signature'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

  • add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
  • install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "crypto": false }

ERROR in ./node_modules/destroy/index.js 12:17-41

Module not found: Error: Can't resolve 'fs' in '/home/mpeubey/Oncobase/front2/node_modules/destroy'

ERROR in ./node_modules/etag/index.js 18:13-30

Module not found: Error: Can't resolve 'crypto' in '/home/mpeubey/Oncobase/front2/node_modules/etag'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

  • add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
  • install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "crypto": false }

ERROR in ./node_modules/etag/index.js 20:12-31

Module not found: Error: Can't resolve 'fs' in '/home/mpeubey/Oncobase/front2/node_modules/etag'

ERROR in ./node_modules/express/lib/application.js 28:11-26

Module not found: Error: Can't resolve 'http' in '/home/mpeubey/Oncobase/front2/node_modules/express/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

  • add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
  • install 'stream-http' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "http": false }

ERROR in ./node_modules/express/lib/request.js 22:11-26

Module not found: Error: Can't resolve 'http' in '/home/mpeubey/Oncobase/front2/node_modules/express/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

  • add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
  • install 'stream-http' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "http": false }

ERROR in ./node_modules/express/lib/response.js 23:11-26

Module not found: Error: Can't resolve 'http' in '/home/mpeubey/Oncobase/front2/node_modules/express/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

  • add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
  • install 'stream-http' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "http": false }

ERROR in ./node_modules/express/lib/view.js 18:9-22

Module not found: Error: Can't resolve 'fs' in '/home/mpeubey/Oncobase/front2/node_modules/express/lib'

ERROR in ./node_modules/mime/mime.js 3:9-22

Module not found: Error: Can't resolve 'fs' in '/home/mpeubey/Oncobase/front2/node_modules/mime'

ERROR in ./node_modules/send/index.js 29:9-22

Module not found: Error: Can't resolve 'fs' in '/home/mpeubey/Oncobase/front2/node_modules/send'

ERROR in ./node_modules/zlib/lib/zlib.js 1:0-43

Module not found: Error: Can't resolve './zlib_bindings' in '/home/mpeubey/Oncobase/front2/node_modules/zlib/lib'

I tried to delete node_modules and npm i, but the problem persists.

I also tried to install the packages separately but idem, the problem is still there

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
Ailleurs
  • 31
  • 1
  • 6

2 Answers2

1

Step 1

Install path-browserify, browserify-zlib, stream-http, crypto-browserify and react-app-rewired

npm install path-browserify browserify-zlib stream-http crypto-browserify react-app-rewired

Step 2

In your project root, create config-overrides.js file.

In this file, put this.

module.exports = function override (config, env) {
    console.log('override...')
    let loaders = config.resolve
    loaders.fallback = {
        "fs": false,
        "http": require.resolve("stream-http"),
        "zlib": require.resolve("browserify-zlib") ,
        "path": require.resolve("path-browserify"),
        "crypto": require.resolve("crypto-browserify")
    }
    
    return config
}

Step 3

important !

Change "start": react-scripts start in your package.json to "start": react-app-rewired start

Now, restart your project.

npm start
Ridoine12
  • 11
  • 2
0

Any module not found You Can perform 3 steps first

First :

npm install modulename

OR

yarn add modulename

Second:

delete node_module && package-lock.json

run npm install or yarn add,

Third :

Error not solve goto package.json specify

dependency{package:"latest"}

or specify dependency version as per requirement and check that dependency or library you are using that is in the list

dependency{package:"^*.*.*"}

and follow step 2

and a specific solution check that on which specific npm & node version the app is build then install that version of npm & node

If that not solve the error then there is programming error or something else.

Specific in your case check each dependencies

HOPE YOUR PROBLEM CAN BE SOLVE