发生未处理的异常:脚本文件 ../node_modules/chart.js 不存在
An unhandled exception occurred: Script file ../node_modules/chart.js does not exist
我正在尝试在我的 Angular 项目上使用 PrimeNG,我创建了一个新项目并尝试启动,但它给了我这个错误,我执行了以下步骤:
npm install primeng --save
npm install @angular/animations --save
npm install Chart.js --save
npm uninstall ng2-charts
我在 Angular.json
中添加了 ../node_modules/chart.js/dist/Chart.js
当我尝试使用 ng serve
运行 我的项目时,出现以下错误:
An unhandled exception occurred: Script file ../node_modules/chart.js
does not exist
任何帮助都是有用的,谢谢。
编辑:
这是我的 Angular.json 的一部分:
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/YarbiTkhdem",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
"scripts": ["../node_modules/chart.js/dist/Chart.js"]
},
您的 angular json
中不需要 chartjs 脚本
"scripts": ["../node_modules/chart.js/dist/Chart.js"]
并且您可以使用 :
向 charjs 添加类型
npm install --save @types/chart.js
发生未处理的异常:脚本文件 node_modules/chart.js/dist/Chart.min.js 不存在。
只需使用 npm install chart.js --save
安装
问题将得到解决
我正在尝试在我的 Angular 项目上使用 PrimeNG,我创建了一个新项目并尝试启动,但它给了我这个错误,我执行了以下步骤:
npm install primeng --save
npm install @angular/animations --save
npm install Chart.js --save
npm uninstall ng2-charts
我在 Angular.json
中添加了../node_modules/chart.js/dist/Chart.js
当我尝试使用 ng serve
运行 我的项目时,出现以下错误:
An unhandled exception occurred: Script file ../node_modules/chart.js does not exist
任何帮助都是有用的,谢谢。
编辑:
这是我的 Angular.json 的一部分:
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/YarbiTkhdem",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
"scripts": ["../node_modules/chart.js/dist/Chart.js"]
},
您的 angular json
中不需要 chartjs 脚本"scripts": ["../node_modules/chart.js/dist/Chart.js"]
并且您可以使用 :
向 charjs 添加类型npm install --save @types/chart.js
发生未处理的异常:脚本文件 node_modules/chart.js/dist/Chart.min.js 不存在。
只需使用 npm install chart.js --save
安装问题将得到解决