Chart.js 未使用 NPM 安装

新手上路,请多包涵

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

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

原文由 Hashim 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 410
2 个回答

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

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

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

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

希望这可以帮助!

原文由 David R 发布,翻译遵循 CC BY-SA 3.0 许可协议

我在 后台运行 webpack 服务器 时遇到了同样的问题当我关闭本地服务器时,包安装没有问题。

原文由 Vladimir Parmon 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏