我已经在全球范围内安装了webpack,当我运行webpack
时会说
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no):
我说是的,webpack-cli似乎已正确安装,但我收到一条错误消息,提示
{ Error: Cannot find module 'webpack'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (C:\Users\TOSHIBA\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\TOSHIBA\node_modules\webpack-cli\bin\convert-argv.js:7:24)
at Module._compile (C:\Users\TOSHIBA\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531: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\TOSHIBA\node_modules\webpack-cli\bin\cli.js:228:14)
at Object.parse (C:\Users\TOSHIBA\node_modules\yargs\yargs.js:567:18)
at C:\Users\TOSHIBA\node_modules\webpack-cli\bin\cli.js:206:8
at Object.<anonymous> (C:\Users\TOSHIBA\node_modules\webpack-cli\bin\cli.js:505:3)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at runCommand.then (C:\Users\TOSHIBA\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:143:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
有什么可能出问题?
答案 0 :(得分:0)
尝试npm link webpack-cli
链接项目的全局安装软件包