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! enoentnpm 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
NPM is basically a package manager which acts as a dependency provider. If there are many small packages, required to build a large one, NPM is the one hotspot which will provide us with the packages. Angular-CLI is one of those packages. As far as NG is concerned, it is the core module of Angular.
npm run sets the NODE environment variable to the node executable with which npm is executed. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install , just in case you've forgotten.
npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server. js. It seems like ng serve starts the embedded server whereas npm start starts the Node servers.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With