Error: Cannot find module 'webpack'错误解决

$ npm install webpack -g
 
$ npm install webpack-cli -g
全局安装webpack

$ npm run dev
 
Error: Cannot find module 'webpack'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (E:\webpack\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (E:\webpack\node_modules\webpack-cli\bin\convert-argv.js:7:24)
    at Module._compile (E:\webpack\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at yargs.parse (E:\webpack\node_modules\webpack-cli\bin\cli.js:241:14)
    at Object.parse (E:\webpack\node_modules\yargs\yargs.js:567:18)
    at E:\webpack\node_modules\webpack-cli\bin\cli.js:219:8
    at Object.<anonymous> (E:\webpack\node_modules\webpack-cli\bin\cli.js:538:3)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at module.exports.filename (C:\Users\jinru\AppData\Roaming\npm\node_modules\webpack-cli\node_modules\import-local\index.js:16:66)
    at C:\Users\jinru\AppData\Roaming\npm\node_modules\webpack-cli\bin\cli.js:13:6
    at Object.<anonymous> (C:\Users\jinru\AppData\Roaming\npm\node_modules\webpack-cli\bin\cli.js:538:3)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
解决方法

$ npm link webpack
---------------------

  

上一篇:深拷贝(deep clone)与浅拷贝(shallow clone)


下一篇:SpringBoot+MyBatis+MySQL读写分离(实例)