Home > other >  ng not recognized and npm run can't find package.json
ng not recognized and npm run can't find package.json

Time:09-23

Whenever I try to create a new project with angular I receive the below error:

error message

however I added the path of angular to the environment and set each and every solution on websites.

and if this is a node.js version issue related how can I update it.

CodePudding user response:

ng is the keyword for using angular cli so the correct way to create a new project is to run ng new projectName

Meanwhile a command such as npm run start executes a script in package.json (in this case ng serve). If you run npm run ng new projectName then npm will look for a script called ng some other parameters called new and projectName

CodePudding user response:

To use the angular CLI command to create a new project or component, you need to use the angular CLI that starts with ng. For more help, just type ng help to see the available commands.

npm run ... is used to run the scripts available in your package.json such as npm run start, npm run test and more.

So to create a new project, the correct command is ng new auto-project or with npx npx ng new auto-project.

  • Related