简体   繁体   中英

Failed to create new project in Angular

When I'm trying to create a new project in Angular using ng new my-first-project I get the result as follows:

? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? CSS
CREATE my-first-project/angular.json (3646 bytes)
CREATE my-first-project/package.json (1249 bytes)
CREATE my-first-project/README.md (1031 bytes)
CREATE my-first-project/tsconfig.json (489 bytes)
CREATE my-first-project/tslint.json (3125 bytes)
CREATE my-first-project/.editorconfig (274 bytes)
CREATE my-first-project/.gitignore (631 bytes)
CREATE my-first-project/browserslist (429 bytes)
CREATE my-first-project/karma.conf.js (1028 bytes)
CREATE my-first-project/tsconfig.app.json (210 bytes)
CREATE my-first-project/tsconfig.spec.json (270 bytes)
CREATE my-first-project/src/favicon.ico (948 bytes)
CREATE my-first-project/src/index.html (300 bytes)
CREATE my-first-project/src/main.ts (372 bytes)
CREATE my-first-project/src/polyfills.ts (2835 bytes)
CREATE my-first-project/src/styles.css (80 bytes)
CREATE my-first-project/src/test.ts (753 bytes)
CREATE my-first-project/src/assets/.gitkeep (0 bytes)
CREATE my-first-project/src/environments/environment.prod.ts (51 bytes)
CREATE my-first-project/src/environments/environment.ts (662 bytes)
CREATE my-first-project/src/app/app-routing.module.ts (246 bytes)
CREATE my-first-project/src/app/app.module.ts (393 bytes)
CREATE my-first-project/src/app/app.component.html (25757 bytes)
CREATE my-first-project/src/app/app.component.spec.ts (1089 bytes)
CREATE my-first-project/src/app/app.component.ts (220 bytes)
CREATE my-first-project/src/app/app.component.css (0 bytes)
CREATE my-first-project/e2e/protractor.conf.js (808 bytes)
CREATE my-first-project/e2e/tsconfig.json (214 bytes)
CREATE my-first-project/e2e/src/app.e2e-spec.ts (649 bytes)
CREATE my-first-project/e2e/src/app.po.ts (301 bytes)
- Installing packages...'npm' is not recognized as an internal or external command,
operable program or batch file.
"× Package install failed, see above."
The Schematic workflow failed. See above.

Can anyone help me with this error, every single time I'm trying to create a new project I'm getting the same error.

First, open your command prompt as Run as administrator there you can install angular using the command npm install -g @angular/cli then it will install globally in your PC. when you try to install the angular into PC using cmd you might open regular cmd , here is the fault that we have to open the cmd in administrator mode then you install your angular. After finishing installation you can run angular by creating a new project using the command ng new first-project then it works fine and you can start your project by npm start or ng serve both will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM