Reputation: 99
C:\Users\shagy\Desktop\3RD YEAR 2ND SEMESTER\SPM\Newfolder\SPM-SMS>npm start
npm ERR! path C:\Users\shagy\Desktop\3RD YEAR 2ND SEMESTER\SPM\New folder\SPM-SMS\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\shagy\Desktop\3RD YEAR 2ND SEMESTER\SPM\New folder\SPM-SMS\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\shagy\AppData\Roaming\npm-cache\_logs\2018-09-05T14_23_49_736Z-debug.log
How to resolve this issue? Even after npm install
, this error is showing up
Upvotes: 5
Views: 36677
Reputation: 6420
This is related to npm not being able to find a file. The error-message npm ERR! enoent
is telling you that the file can't be found.
First check if the file actually exists on your fs under that path and check the reference-path you use to call that file for possible typos.
If this is a fresh project you can call
npm init
and node will initliaize your project and create a package.json
for you..
From the official docs:
Description: npm init can be used to set up a new or existing npm package.
initializer in this case is an npm package named create-, which >will be installed by npx, and then have its main bin executed -- presumably >creating or updating package.json and running any other initialization-related >operations.
The init command is transformed to a corresponding npx operation as follows:
- npm init foo -> npx create-foo
- npm init @usr/foo -> npx @usr/create-foo
- npm init @usr -> npx @usr/create
Any additional options will be passed directly to the command, so npm init foo --hello will map to npx create-foo --hello.
If the initializer is omitted (by just calling npm init), init will fall back to legacy init behavior. It will ask you a bunch of questions, and then write a package.json for you. It will attempt to make reasonable guesses based on existing fields, dependencies, and options selected. It is strictly additive, so it will keep any fields and values that were already set. You can also use -y/--yes to skip the questionnaire altogether. If you pass --scope, it will create a scoped package.
For more detailed information please read the official docs about npm init.
Upvotes: 8
Reputation: 61
this happened with me,too. I turned out i was in the wrong directory when I run the npm command, this is why I got the error messages. Changignt the directory with the cd command resolved the issue for me.
Upvotes: 6
Reputation: 89
Validate your path "C:\Users\shagy\Desktop\3RD YEAR 2ND SEMESTER\SPM\New folder\SPM-SMS" does this really has package.json file? if no then you have to install npm again (command "npm init") to ensure package.json file appears in the same directory as mentioned in your error. Hope this helps!
Upvotes: 0