Jason Kahn
Jason Kahn

Reputation: 1

Angular13 Issues when running npm start

Versions ->

PS C:\Users\user> npm --version
8.8.0
PS C:\Users\user> node --version
v16.15.0

Then i Run the next command->

npx -p @angular/cli ng new JokeFrontB

enter image description here

Then I just run Serve -> npm start

and I get the following

PS D:\C#\JokeSaver\JokeFrontB> npm start

> [email protected] start
> ng serve

√ Browser application bundle generation complete.

Initial Chunk Files | Names         |  Raw Size
vendor.js           | vendor        |   1.81 MB |
polyfills.js        | polyfills     | 123.15 kB |
main.js             | main          |  50.54 kB |
runtime.js          | runtime       |   6.35 kB |
styles.css          | styles        |   1.27 kB |

                    | Initial Total |   1.99 MB

Build at: 2022-05-03T01:01:34.976Z - Hash: 28244047a1cd8312 - Time: 11880ms

    Error: Module not found: Error: Can't resolve 'D:/C#/JokeSaver/JokeFrontB/src/app/app.component.scss?ngResource' in 'D:\C#\JokeSaver\JokeFrontB'
    
    Error: Module not found: Error: Can't resolve 'D:\C#\JokeSaver\JokeFrontB\node_modules\webpack-dev-server\client\index.js?protocol=auto%3A&username=&password=&hostname=0.0.0.0&port=0&pathname=%2Fws&logging=info&reconnect=10' in 'D:\C#\JokeSaver\JokeFrontB'
    
    Error: The loader "D:/C#/JokeSaver/JokeFrontB/src/app/app.component.scss" didn't return a string.



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


× Failed to compile.

I have no idea what it could be...

Package.json looks like this

  {
      "name": "joke-front-b",
      "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.3.0",
        "@angular/common": "~13.3.0",
        "@angular/compiler": "~13.3.0",
        "@angular/core": "~13.3.0",
        "@angular/forms": "~13.3.0",
        "@angular/platform-browser": "~13.3.0",
        "@angular/platform-browser-dynamic": "~13.3.0",
        "@angular/router": "~13.3.0",
        "rxjs": "~7.5.0",
        "tslib": "^2.3.0",
        "zone.js": "~0.11.4"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~13.3.4",
        "@angular/cli": "~13.3.4",
        "@angular/compiler-cli": "~13.3.0",
        "@types/jasmine": "~3.10.0",
        "@types/node": "^12.11.1",
        "jasmine-core": "~4.0.0",
        "karma": "~6.3.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.1.0",
        "karma-jasmine": "~4.0.0",
        "karma-jasmine-html-reporter": "~1.7.0",
        "typescript": "~4.6.2"
      }
    }
    
    
    tsconfig.json looks like this
    
    {
      "compileOnSave": false,
      "compilerOptions": {
        "baseUrl": "./",
        "outDir": "./dist/out-tsc",
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitOverride": true,
        "noPropertyAccessFromIndexSignature": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "sourceMap": true,
        "declaration": false,
        "downlevelIteration": true,
        "experimentalDecorators": true,
        "moduleResolution": "node",
        "importHelpers": true,
        "target": "es2017",
        "module": "es2020",
        "lib": [
          "es2020",
          "dom"
        ]
      },
      "angularCompilerOptions": {
        "enableI18nLegacyMessageIdFormat": false,
        "strictInjectionParameters": true,
        "strictInputAccessModifiers": true,
        "strictTemplates": true
      }
    }
    
    

angular.json

    {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "version": 1,
      "newProjectRoot": "projects",
      "projects": {
        "JokeFrontB": {
          "projectType": "application",
          "schematics": {
            "@schematics/angular:component": {
              "style": "scss"
            },
            "@schematics/angular:application": {
              "strict": true
            }
          },
          "root": "",
          "sourceRoot": "src",
          "prefix": "app",
          "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist/joke-front-b",
                "index": "src/index.html",
                "main": "src/main.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "tsconfig.app.json",
                "inlineStyleLanguage": "scss",
                "assets": [
                  "src/favicon.ico",
                  "src/assets"
                ],
                "styles": [
                  "src/styles.scss"
                ],
                "scripts": []
              },
              "configurations": {
                "production": {
                  "budgets": [
                    {
                      "type": "initial",
                      "maximumWarning": "500kb",
                      "maximumError": "1mb"
                    },
                    {
                      "type": "anyComponentStyle",
                      "maximumWarning": "2kb",
                      "maximumError": "4kb"
                    }
                  ],
                  "fileReplacements": [
                    {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.prod.ts"
                    }
                  ],
                  "outputHashing": "all"
                },
                "development": {
                  "buildOptimizer": false,
                  "optimization": false,
                  "vendorChunk": true,
                  "extractLicenses": false,
                  "sourceMap": true,
                  "namedChunks": true
                }
              },
              "defaultConfiguration": "production"
            },
            "serve": {
              "builder": "@angular-devkit/build-angular:dev-server",
              "configurations": {
                "production": {
                  "browserTarget": "JokeFrontB:build:production"
                },
                "development": {
                  "browserTarget": "JokeFrontB:build:development"
                }
              },
              "defaultConfiguration": "development"
            },
            "extract-i18n": {
              "builder": "@angular-devkit/build-angular:extract-i18n",
              "options": {
                "browserTarget": "JokeFrontB:build"
              }
            },
            "test": {
              "builder": "@angular-devkit/build-angular:karma",
              "options": {
                "main": "src/test.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "tsconfig.spec.json",
                "karmaConfig": "karma.conf.js",
                "inlineStyleLanguage": "scss",
                "assets": [
                  "src/favicon.ico",
                  "src/assets"
                ],
                "styles": [
                  "src/styles.scss"
                ],
                "scripts": []
              }
            }
          }
        }
      },
      "defaultProject": "JokeFrontB"
    }

What have I tried?

app's folder structure

Upvotes: 0

Views: 917

Answers (1)

Nick Harding
Nick Harding

Reputation: 13

i had the same issue and its do with webpack i believe, it read # as a space and not the character # so change the file structure to d://

Upvotes: 0

Related Questions