【发布时间】:2017-07-04 05:52:22
【问题描述】:
我正在尝试安装 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 所以这是我的包文件的代码(我已经审查了一些私人信息):
{
"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"
}
对这里出了什么问题有任何想法吗?我正在按照文档所说的那样做。如果有人可以测试安装它以查看它是否正常工作,那就太好了。谢谢
【问题讨论】:
-
在 OS X 上对我来说很好用。会不会是您当前目录中没有
package.json文件? -
我有一个 package.json 但重新制作了它,因为我可能做错了。即使重做 package.json,当我尝试使用 NPM 安装 chart.js 时,错误仍然存在
标签: javascript node.js npm chart.js npm-install