欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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版本后可以正常打包