Home > Net >  Basic "ng serve" app fails to run after creating "ng new FirstApp"
Basic "ng serve" app fails to run after creating "ng new FirstApp"

Time:11-15

main.ts - Error: Module build failed: Error: Cannot find module-@angular-devkit\build-angular\src\babel\webpack-loader.js

app.component.scss - Error: Module build failed- node_modules/postcss-loader/dist/cjs.js

Module not found: Error: Can't resolve index.js?protocol=auto:&username=&password=&hostname=0.0.0.0&port=0&pathname=/ws&logging=info&reconnect=10'

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

× Failed to compile. https://i.stack.imgur.com/8T8HO.jpg

package.json

{
  "name": "first-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.0.0",
    "@angular/common": "~13.0.0",
    "@angular/compiler": "~13.0.0",
    "@angular/core": "~13.0.0",
    "@angular/forms": "~13.0.0",
    "@angular/platform-browser": "~13.0.0",
    "@angular/platform-browser-dynamic": "~13.0.0",
    "@angular/router": "~13.0.0",
    "rxjs": "~7.4.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.0.1",
    "@angular/cli": "~13.0.1",
    "@angular/compiler-cli": "~13.0.0",
    "@types/jasmine": "~3.10.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.10.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.4.3"
  }
}

CodePudding user response:

This looks like environmental issue. I did tried on my local machine from scratch and this works with no issues. try cleaning your local directory completely and run following:

ng new FirstApp 
cd FirstApp 
ng serve 
  • Related