我查看并执行了这篇文章中 的几乎每一个答案:CLI 移到了一个单独的包中:webpack-cli 它没有帮助。
请允许我介绍我的情况:
所以我开发了一个容器文件夹,一个单独的应用程序,我在其中运行npm init -y
然后安装了以下内容:
npm install html-webpack-plugin@4.5.0 nodemon webpack@5.3.2 webpack-cli@4.1.0 webpack-dev-server@3.11.0
然后我进入我的package.json
文件并添加了启动脚本:
{
"name": "container",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack serve"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"html-webpack-plugin": "^4.5.0",
"nodemon": "^2.0.6",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"
}
}
当我去终端并运行npm start
时,这就是为什么我每次都会得到:
➜ container npm start
> container@1.0.0 start /Users/luiscortes/Projects/ecommRS/container
> webpack serve
[webpack-cli] The command moved into a separate package: @webpack-cli/serve
? Would you like to install @webpack-cli/serve? (That will run npm install -D @webpack-cli/serve) (Y/n) › true
是的,即使我选择Y
ortrue
并且它运行它npm install -D @webpack-cli/serve
,当我重新运行npm start
它时,它只会一遍又一遍地给我同样的错误。