gpt4 book ai didi

angular - 无法读取 null TypeError : Cannot read property 的属性 'config'

转载 作者:行者123 更新时间:2023-12-05 01:17:56 25 4
gpt4 key购买 nike

当我运行这个命令 ng serve 时,我有这个错误,谁能告诉我为什么

Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (C:\wamp64\www\back_front\front_end\node_modules\@angular\cli\tasks\serve.js:51:63) at check_port_1.checkPort.then.port (C:\wamp64\www\back_front\front_end\node_modules\@angular\cli\commands\serve.js:123:26) at process._tickCallback (internal/process/next_tick.js:109:7)

最佳答案

当 Angular 找不到 .angular-cli.json 文件时会发生此错误(请注意文件名中有一个点)。通常它是一个隐藏文件。

先尝试以下步骤:

  • 删除你的 node_modules 文件夹和 package-lock.json 文件
  • npm 安装
  • npm 卸载 -g angular-cli
  • npm 卸载 -g @angular/cli
  • npm install -g @angular/cli
  • 服务

如果它仍然产生同样的错误,那么你实际上需要 .angular-cli.json 文件。

默认 .angular-cli.json 文件:

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "PROJECT_NAME"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}

注意:这只是一个默认文件,您需要在此文件中配置您的项目设置。

关于angular - 无法读取 null TypeError : Cannot read property 的属性 'config',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48122753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com