Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  39] [ 3]  / answers: 1 / hits: 16162  / 7 Years ago, tue, july 4, 2017, 12:00:00

I am trying to install chart.js . Their documentation for how to install the package with NPM is here : http://www.chartjs.org/docs/latest/getting-started/installation.html



It says to enter the following with NPM to install.



npm install chart.js --save


However, it doesn't work for me. I get the followin error in my console when I try to install chart.js with NPM.



C:UsersHashim AHmedDesktopHashimcodingProject_PlasmaBirdyahoo_finance>npm install chart.js --save
npm ERR! not a package (MY PROJECT DIRECTORY)yahoo_financechart.js
npm ERR! addLocal Could not install (MY PROJECT DIRECTORY)yahoo_financechart.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:UsersHASHIM~1AppDataLocalTempnpm-6480-170f285funpack-fccf9cadpackage.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:UsersHASHIM~1AppDataLocalTempnpm-6480-170f285funpack-fccf9cadpackage.json'
npm ERR! enoent ENOENT: no such file or directory, open 'C:UsersHASHIM~1AppDataLocalTempnpm-6480-170f285funpack-fccf9cadpackage.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:


EDIT: As some have pointed out, the error may lie in my Package.json so here is the code of my package file (i have censored out some private info) :



{
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
}


Any ideas of what's going wrong here? I am doing exactly as the documentation is saying. If someone could test install this to see if it is working, that would be great. Thanks


More From » node.js

 Answers
70

You need to have the package.json file in your directory to have this chart.js module saved locally.



To create a package.json file, use the below command,



npm init (which will ask you few questions and will create the file at the end).



Once you create your package.json try executing the npm install chart.js --save command and see if it works.



Hope this helps!


[#57219] Friday, June 30, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ciarajourneyv

Total Points: 428
Total Questions: 95
Total Answers: 90

Location: Maldives
Member since Sat, Feb 11, 2023
1 Year ago
;