Chart.js没有安装NPM

时间:2017-07-04 05:52:22

标签: javascript node.js npm chart.js npm-install

我正在尝试安装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"
}

关于这里出了什么问题的任何想法?我正在按照文档说的那样做。如果有人可以测试安装它以查看它是否正常工作,那就太棒了。感谢

2 个答案:

答案 0 :(得分:1)

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

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

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

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

希望这有帮助!

答案 1 :(得分:-1)

使用npm安装chart.js时,我遇到了同样的问题。

似乎您必须停止 ng服务,然后尝试 npm install chart.js --save ,因为我尝试了相同的操作,并且在同一文件夹中也能正常工作