gpt4 book ai didi

javascript - Chart.js 未随 NPM 安装

转载 作者:太空宇宙 更新时间:2023-11-04 02:04:14 25 4
gpt4 key购买 nike

我正在尝试安装 Chart.js 。他们关于如何使用 NPM 安装软件包的文档位于:http://www.chartjs.org/docs/latest/getting-started/installation.html

它说要使用 NPM 输入以下内容来安装。

npm install chart.js --save

但是,这对我不起作用。当我尝试使用 NPM 安装 Chart.js 时,我的控制台中出现以下错误。

C:\Users\Hashim AHmed\Desktop\Hashim\coding\Project_PlasmaBird\yahoo_finance>npm install chart.js --save
npm ERR! not a package (MY PROJECT DIRECTORY)\yahoo_finance\chart.js
npm ERR! addLocal Could not install (MY PROJECT DIRECTORY)\yahoo_finance\chart.js
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "chart.js" "--save"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! path C:\Users\HASHIM~1\AppData\Local\Temp\npm-6480-170f285f\unpack-fccf9cad\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\HASHIM~1\AppData\Local\Temp\npm-6480-170f285f\unpack-fccf9cad\package.json'
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\HASHIM~1\AppData\Local\Temp\npm-6480-170f285f\unpack-fccf9cad\package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR! (mydirectory)\npm-debug.logwing error:

编辑:正如一些人指出的,错误可能存在于我的 Package.json 中,所以这里是我的包文件的代码(我已经审查了一些私有(private)信息):

{
"name": "projectplasma",
"version": "1.0.0",
"description": "projectplasma",
"main": "index.js",
"dependencies": {
"colors": "^1.1.2",
"yahoo-finance": "^0.3.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/(my username)/(my repo).git"
},
"keywords": [
"stk"
],
"author": "Hashim",
"license": "ISC",
"bugs": {
"url": "https://github.com/(myusername)/(my repo)/issues"
},
"homepage": "https://github.com/(my username)/(my repo)#readme"
}

你知道这里出了什么问题吗?我完全按照文档所说的做。如果有人可以测试安装它以查看它是否有效,那就太好了。谢谢

最佳答案

您的目录中需要有 package.json 文件才能将此 chart.js 模块保存在本地。

要创建 package.json 文件,请使用以下命令,

npm init(它会问你几个问题,并在最后创建文件)。

创建 package.json 后,尝试执行 npm install Chart.js --save 命令并查看它是否有效。

希望这有帮助!

关于javascript - Chart.js 未随 NPM 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44897870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com