webpack打包报错:Cannot find module 'resolve-cwd'
程序员文章站
2022-06-01 09:27:28
...
环境介绍:
新建的webpack工程,工程使用的webpack版本为4.x,在打包时报错
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'resolve-cwd'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /usr/local/lib/node_modules/webpack-cli/bin/webpack.js:11:21
at Object.<anonymous> (/usr/local/lib/node_modules/webpack-cli/bin/webpack.js:512:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
最后排查原因是由于打包的webpack版本为2.x,过于老旧。更新webpack版本后可以正常打包
推荐阅读
-
webpack-dev-server config.js Cannot find module
-
【已解决】运行webpack-dev-server时提示Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
webpack5: Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
Webpack 报错:Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
webpack-dev-server 报错 Error: Cannot find module ‘webpack/bin/config-yargs‘
-
webpack——Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
【webpack-dev-server】Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
Error: Cannot find module 'webpack-cli/bin/config-yargs' at Function.Module._resolveFilename
-
【webpack】Error: Cannot find module webpack-cli/bin/config-yargs
-
[one day one question] webpack 打包报错 Cannot assign to read only property 'exp