我克隆了我的旧项目并运行npm install
,之后我运行ionic serve
我发现了这个错误
[ERROR] @ionic/app-scripts is required for ionic serve to work properly.
Looks like @ionic/app-scripts isn't installed in this project.
This package is required for ionic serve in ionic/angular 4 projects.
你的问题标题本身就有答案。
尝试安装以下内容
npm install @ionic/app-scripts@latest --save-dev
删除node_modules文件夹
跑:
npm install
等到它完成。现在您可以使用以下命令运行项目:
ionic serve -l
我在更新到Ionic 4后遇到了这个问题。我最终不得不降级。
退出命令面板并再次重新打开。它的作品。
除了删除node_modules并运行@tnfaid所提到的npm install
之外,我还删除了package-lock.json
文件以确定。还运行npm audit fix
,以解决任何漏洞。这对我有用。
跑:
npm update
这将使一切都很好。
当我从Ionic 3升级到4时,发生了这种情况。问题是package.json
和ionic.config.json
都从3变为4.所以当你进行复制粘贴操作时,你必须要小心。
angular
(used to be "type": "ionic-angular"){
"name": "myProjectName",
"integrations": {
"cordova": {}
},
"type": "angular"
}
你可能有这样的事情
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint --bailOnLintError true",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"ionic:watch:before": "node ./bin/pre-build.js",
"ionic:build:before": "node ./bin/pre-build.js"
},
现在应该改为Ionic 4中的标准角度:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},