我想让es6到我的项目,所以我用这个教程this tutorial,当我试图写'webpack'在cmd我得到的错误
Done in 8.99s.
{ Error: Cannot find module 'webpack-cli'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at runCommand.then.result (C:\Users\adirz\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14)
at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NOT_FOUND' }
package.json
{
"name": "functions",
"scripts": {
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.1"
},
"devDependencies": {
"ts-loader": "^4.2.0",
"typescript": "^2.5.3",
"webpack": "^4.5.0",
"webpack-cli": "^2.0.14",
"webpack-node-externals": "^1.7.2"
},
"private": true
}
我的文件夹结构
6条答案
按热度按时间ercv8c1e1#
请尝试使用:
npm i -g webpack-cli
。以下是Github上的官方问题:https://github.com/webpack/webpack-cli/issues/191
n9vozmp42#
将全局安装的软件包链接到项目
yk9xbfzb3#
这为我解决了问题
https://flaviocopes.com/npm-fix-missing-write-access-error/
t5zmwmid4#
对我来说,问题是我没有使用'sudo'权限。如果你使用的是基于linux的系统,请尝试输入
sudo npm i -g webpack-cli
bweufnob5#
我也遇到过类似的错误。对我来说,答案是确保整个项目路径没有空格、&或任何其他奇怪的字符。
7fyelxc56#
如果您使用Yarn代替NPM全局运行Webpack,可以使用以下命令安装webpack:
和或