简体   繁体   English

如何在我的 AngularJS 项目中包含 Chart.js?

[英]How to include Chart.js in my AngularJS project?

I'm new to AngularJS and I'm currently working on building an application on Ubuntu.我是 AngularJS 的新手,目前正在 Ubuntu 上构建应用程序。 When I'm trying to install Chart.js using npm install chart.js , it is throwing the following error .当我尝试使用npm install chart.js时,它抛出以下错误

 npm WARN karma-jasmine-html-reporter@1.5.1 requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/webpack-dev-server/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/watchpack/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/karma/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/@angular/compiler-cli/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) + chart.js@2.9.3 updated 1 package and audited 19058 packages in 9.013s 23 packages are looking for funding run `npm fund` for details found 0 vulnerabilities

What does this error mean?这个错误是什么意思?

How do I fix this?我该如何解决?

Is there any other way to include Chart.js in my project other than the install command?除了安装命令之外,还有其他方法可以在我的项目中包含 Chart.js 吗?

There are 0 vulnerabilities in your install.您的安装中存在 0 个漏洞。 what you call error is just WARN means warnings, which can be ignored, Chart.js has successfully installed. what you call error is just WARN means warnings, which can be ignored, Chart.js已成功安装。 you should be good to go.你应该可以开始了。

If you want to get rid of these warnings, as it says You must install peer dependencies yourself.如果你想摆脱这些警告,正如它所说, You must install peer dependencies yourself.

Try npm install jasmine-core@>=3.5尝试 npm install jasmine-core@>=3.5

npm decided to add a new command: npm fund that will provide more visibility to npm users on what dependencies are actively looking for ways to fund their work. npm 决定添加一个新命令:npm fund,这将为 npm 用户提供更多可见性,让他们了解哪些依赖项正在积极寻找为他们的工作提供资金的方法。

npm install will also show a single message at the end in order to let user aware that dependencies are looking for funding, it looks like this: npm install 也会在最后显示一条消息,以便让用户知道依赖项正在寻找资金,它看起来像这样:

$ npm install
13 packages are looking for funding.
run `npm fund` for details.

Running npm fund will open the url listed for that given package right in your browser.运行 npm fund 将在您的浏览器中打开为该给定包列出的 url。

npm funding does not mean that the package is not installed, your package is successfully installed. npm 资助并不意味着没有安装包,你的包安装成功了。

please check this for more information请检查此以获取更多信息

you didnt get any errors only warnings, you can ignore them.你没有收到任何错误警告,你可以忽略它们。 first of all you can download manually from https://github.com/jtblin/angular-chart.js but you already installed them from npm so try to include it in your project首先,您可以从https://github.com/jtblin/angular-chart.js手动下载,但您已经从 npm 安装了它们,因此请尝试将其包含在您的项目中

when you load your angular module dont forget to use当你加载你的角度模块时,不要忘记使用

angular.module('myModule', ['chart.js']);

let us know if you were able to use it, best of luck !如果您能够使用它,请告诉我们,祝您好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM