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

$ npm install webpack -g

$ npm install webpack-cli -g

全局安装webpack

webpack hello.js -o hello.bundle.js

运行一个已经创建的hello.js文件报错

E:\webpack\node_modules\webpack-cli\bin\cli.js:244
                                throw err;
                                ^

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

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值