Solve’npm WARN saveError ENOENT: no such file or directory, please open’/Users/<username>/package.json” error
Home/npm warn saveerror enoent: no such file or directory
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
422822993
New to nodejs and npm, follow the tutorial to introduce modules in npm, (Tutorial: http://blog.csdn.net/binyao02...) Execute npm install formidable, then an error is reported no such file or directory No description, No repo-field, No README-data, No license-field Then I changed to execute npm instaRead more
New to nodejs and npm, follow the tutorial to introduce modules in npm,
(Tutorial: http://blog.csdn.net/binyao02…)
Execute npm install formidable, then an error is reported
no such file or directory
No description,
No repo-field,
No README-data,
No license-field
Then I changed to execute npm install (I learned that this command updates the npm package (I don’t know if it is?))
But npm install reported the same error. The screenshot is as follows: (SF uploading pictures function is suspended)
C:\Users\fanzm1\workspace\Astone\0115_NodeJS>npm install formidable
npm WARN saveError ENOENT: no such file or directory, open ‘C:\Users\fanzm1\workspace\Astone\0115_NodeJS\package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\fanzm1\workspace\Astone\0115_NodeJS\package.json’
npm WARN 0115_NodeJS No description
npm WARN 0115_NodeJS No repository field.
npm WARN 0115_NodeJS No README data
npm WARN 0115_NodeJS No license field.
+ formidableadmin.1.1
added 1 package in 1.475s
C:\Users\fanzm1\workspace\Astone\0115_NodeJS>npm install
npm WARN saveError ENOENT: no such file or directory, open ‘C:\Users\fanzm1\workspace\Astone\0115_NodeJS\package.json’
npm WARN enoent ENOENT: no such file or directory, open ‘C:\Users\fanzm1\workspace\Astone\0115_NodeJS\package.json’
npm WARN 0115_NodeJS No description
npm WARN 0115_NodeJS No repository field.
npm WARN 0115_NodeJS No README data
npm WARN 0115_NodeJS No license field.
up to date in 0.116s
Question:
① How can I install the npm module correctly?
① How to use npm install correctly? (Does it have to be used in the npm installation directory? (It seems not…))
② Do I need a package.json (previous classmates told me that if there is no “package.json” under the directory, npm will not be able to install it)?
③ If yes, how to generate package.json?
Cause of error
Look at this prompt, because the package.json file is missing.
Solution:
First, initialize the project and press Enter all the way
npm init -f
Then install dependencies
npm install formidable –save
See less