首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行npm启动时Angular13问题

运行npm启动时Angular13问题
EN

Stack Overflow用户
提问于 2022-05-03 01:22:51
回答 1查看 539关注 0票数 0

版本->

代码语言:javascript
复制
PS C:\Users\user> npm --version
8.8.0
PS C:\Users\user> node --version
v16.15.0

然后运行下一个命令->

代码语言:javascript
复制
npx -p @angular/cli ng new JokeFrontB

然后我只运行服务-> npm start

我得到以下信息

代码语言:javascript
复制
PS D:\C#\JokeSaver\JokeFrontB> npm start

> joke-front-b@0.0.0 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.

我不知道会是什么..。

Package.json看起来像这样

代码语言:javascript
复制
  {
      "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

代码语言:javascript
复制
    {
      "$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"
    }

我试过什么?

  • 安装npm节点和角节点的旧版本。
  • 全球最新安装角钢
  • 全局安装角旧版本
  • 创建一个项目,删除node_modules并运行npm
  • 删除node_modules和package.json并运行npm安装
  • 尝试在安装最新版本的rxjs上获得相同的版本。

app文件夹结构

EN

回答 1

Stack Overflow用户

发布于 2022-05-23 23:34:14

我和webpack也有过同样的问题,我相信,它是一个空格,而不是字符#,所以将文件结构更改为d://

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72093964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档