[Fixed] Angular – npm ERR! enoent This is related to npm not being able to find a file.

Issue

So I’m trying to make a new angular app for the first time, and I installed it using npm i -g @angular/cli. When I try to make a new app using npm run ng new app, it gives me this error:

npm ERR! path E:\ddii\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open ‘E:\ddii\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…\AppData\Roaming\npm-cache_logs\2018-09-10T20_22_50_118Z-debug.log

enter image description here
enter image description here

Solution

In short, you are running the command incorrectly. Remove the npm run from the front of your command, and it should work.

When you say npm run blah, npm does a lookup in your package.json for a script called blah or in your case ng. So… if you are running npm run ng new app, npm wants there to be a package.json in your current directory, and in that package.json, npm expect a script called ng. So if you don’t have a package.json in your current dir, then you are going to get an error.

Instead, close your terminal, and open a new terminal and run simply ng new app.

Leave a Reply

(*) Required, Your email will not be published