webpack打包报错:Cannot find module 'resolve-cwd'

环境介绍:
        新建的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. (/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打包报错:Cannot find module 'resolve-cwd')