webpack打包失败问题

来源:2-1 建立项目的 webpack 配置文件

qq_零_139

2019-01-20 23:11

我输入打包命令 webpack 为什么没有打包成功,报错信息为:

D:\webpack-test>webpack

C:\Users\Administrator\node_modules\webpack-cli\bin\cli.js:244

                                throw err;

                                ^


Error: Cannot find module 'webpack'

    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)

    at Function.Module._load (internal/modules/cjs/loader.js:507:25)

    at Module.require (internal/modules/cjs/loader.js:637:17)

    at require (C:\Users\Administrator\node_modules\v8-compile-cache\v8-compile-

cache.js:159:20)

    at Object.<anonymous> (C:\Users\Administrator\node_modules\webpack-cli\bin\c

onvert-argv.js:7:24)

    at Module._compile (C:\Users\Administrator\node_modules\v8-compile-cache\v8-

compile-cache.js:178:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

    at Module.load (internal/modules/cjs/loader.js:599:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

    at Module.require (internal/modules/cjs/loader.js:637:17)

    at require (internal/modules/cjs/helpers.js:22:18)

    at yargs.parse (C:\Users\Administrator\node_modules\webpack-cli\bin\cli.js:2

41:14)

    at Object.parse (C:\Users\Administrator\node_modules\webpack-cli\node_module

s\yargs\yargs.js:563:18)

    at C:\Users\Administrator\node_modules\webpack-cli\bin\cli.js:219:8

    at Object.<anonymous> (C:\Users\Administrator\node_modules\webpack-cli\bin\c

li.js:530:3)

    at Module._compile (internal/modules/cjs/loader.js:689:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

    at Module.load (internal/modules/cjs/loader.js:599:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

    at Module.require (internal/modules/cjs/loader.js:637:17)

    at require (internal/modules/cjs/helpers.js:22:18)

    at Object.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modul

es\webpack\bin\webpack.js:155:2)

    at Module._compile (internal/modules/cjs/loader.js:689:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

    at Module.load (internal/modules/cjs/loader.js:599:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)


写回答 关注

1回答

  • acoderdohiswork
    2019-01-21 14:45:01
    已采纳

    4.0+版本,执行webpack命令之前先执行npm install --save-dev webpack-cli 试试

webpack深入与实战

webpack实战教程,用真实项目带你探索 webpack 强大的功能

86561 学习 · 721 问题

查看课程

相似问题