ERROR in ./node_modules/safer-buffer/safer.js
See original GitHub issuewhen I require iconv-lite and build ,I get the error,
ERROR in ./node_modules/safer-buffer/safer.js 5:13-30
Module not found: Error: Can't resolve 'buffer' in 'C:\Users\007\Desktop\mmd-play\node_modules\safer-buffer'
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: { "buffer": require.resolve("buffer/") }'
- install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "buffer": false }
resolve 'buffer' in 'C:\Users\007\Desktop\mmd-play\node_modules\safer-buffer'
Parsed request is a module
using description file: C:\Users\007\Desktop\mmd-play\node_modules\safer-buffer\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
C:\Users\007\Desktop\mmd-play\node_modules\safer-buffer\node_modules doesn't exist or is not a directory
C:\Users\007\Desktop\mmd-play\node_modules\node_modules doesn't exist or is not a directory
looking for modules in C:\Users\007\Desktop\mmd-play\node_modules
single file module
using description file: C:\Users\007\Desktop\mmd-play\package.json (relative path: ./node_modules/buffer)
no extension
C:\Users\007\Desktop\mmd-play\node_modules\buffer doesn't exist
.js
C:\Users\007\Desktop\mmd-play\node_modules\buffer.js doesn't exist
.json
C:\Users\007\Desktop\mmd-play\node_modules\buffer.json doesn't exist
.wasm
C:\Users\007\Desktop\mmd-play\node_modules\buffer.wasm doesn't exist
C:\Users\007\Desktop\mmd-play\node_modules\buffer doesn't exist
C:\Users\007\Desktop\node_modules doesn't exist or is not a directory
C:\Users\007\node_modules doesn't exist or is not a directory
C:\Users\node_modules doesn't exist or is not a directory
C:\node_modules doesn't exist or is not a directory
@ ./node_modules/iconv-lite/lib/index.js 5:13-43
@ ./src/component/model-upload.js 65:12-33
@ ./src/views/contribute/index.js 70:0-55 303:42-53
@ ./src/router/index.js
@ ./src/App.js 39:0-39 57:42-51
@ ./src/index.js 3:0-24 4:50-53
so I add resolve.fallback: { “buffer”: require.resolve(“buffer/”) } to webpack.config.js,but
[webpack-cli] Failed to load 'C:\Users\007\Desktop\mmd-play\webpack.config.js' config
[webpack-cli] Error: Cannot find module 'buffer/'
Require stack:
- C:\Users\007\Desktop\mmd-play\webpack.config.js
- C:\Users\007\Desktop\mmd-play\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\007\Desktop\mmd-play\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\007\Desktop\mmd-play\node_modules\webpack-cli\bin\cli.js
- C:\Users\007\Desktop\mmd-play\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.resolve (C:\Users\007\Desktop\mmd-play\node_modules\v8-compile-cache\v8-compile-cache.js:164:23)
at Object.<anonymous> (C:\Users\007\Desktop\mmd-play\webpack.config.js:25:31)
at Module._compile (C:\Users\007\Desktop\mmd-play\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (C:\Users\007\Desktop\mmd-play\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at WebpackCLI.tryRequireThenImport (C:\Users\007\Desktop\mmd-play\node_modules\webpack-cli\lib\webpack-cli.js:32:22) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\007\\Desktop\\mmd-play\\webpack.config.js',
'C:\\Users\\007\\Desktop\\mmd-play\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\Users\\007\\Desktop\\mmd-play\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\Users\\007\\Desktop\\mmd-play\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\Users\\007\\Desktop\\mmd-play\\node_modules\\webpack\\bin\\webpack.js'
]
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ExpressJs is return error `ERR_MODULE_NOT_FOUND` if ...
If someone is still searching, I got this error using node version 15, I was importing the files without the .js file extension, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
oh,It was build success just for its webpack version is 4, I got the error in version 5
The problem is resolved.I’m stupid,I always thought the error
Error: Cannot find module 'buffer/'
ask me tonpm i buffer/
,however,the correct isnpm i buffer
.So in webpack5,we shouldnpm i buffer
and add a config into webpack.config.js