Node.js 现有项目的角度问题
我在Windows7上 我导入了一个朋友启动的Angular项目,但在安装node和Angular后出现了一些问题,我可以使用以下命令运行该项目:Node.js 现有项目的角度问题,node.js,angular,Node.js,Angular,我在Windows7上 我导入了一个朋友启动的Angular项目,但在安装node和Angular后出现了一些问题,我可以使用以下命令运行该项目: C:\NG\projectName>npm start 但当我尝试使用此命令生成新组件时,我得到一个错误: C:\NG\projectName\app\components>ng g c myNewComponentName installing component Unable to find any apps in `.angula
C:\NG\projectName>npm start
但当我尝试使用此命令生成新组件时,我得到一个错误:
C:\NG\projectName\app\components>ng g c myNewComponentName
installing component
Unable to find any apps in `.angular-cli.json`
angular-cli.json文件位于以下位置:C:\NG\projectName\node\u modules\@angular\cli\blueprints\NG\files\并包含以下代码:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "<%= htmlComponentName %>"
},
"apps": [
{
"root": "<%= sourceDir %>",
"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": "<%= prefix %>",
"styles": [
"styles.<%= styleExt %>"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "<%= sourceDir %>/tsconfig.app.json"
},
{
"project": "<%= sourceDir %>/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "<%= styleExt %>",<% if (!minimal) { %>
"component": {}<% } else { %>
"component": {
"spec": false,
"inlineStyle": true,
"inlineTemplate": true
},
"directive": {
"spec": false
},
"class": {
"spec": false
},
"guard": {
"spec": false
},
"module": {
"spec": false
},
"pipe": {
"spec": false
},
"service": {
"spec": false
} <% } %>
}
}
感谢您的帮助。问题很可能是项目未使用angular cli初始化
在C:\ng\projectName>中运行ng init应该可以解决问题谢谢您的帮助,但我有一个错误:C:\ng\projectName>ng init指定的命令init无效。有关可用选项,请参阅ng help.square。能否运行dir/a:hd C:\NG\projectName以便查看.angular-cli.json是否在根目录中?该文件不在根目录中OK。所以我的错。这另外,.好的,谢谢,我可以安装angular的旧版本来解决此问题吗?
C:\NG\projectName\app\components>ng -v
@angular/cli: 1.2.0
node: 6.11.0
os: win32 x64
@angular/animations: 4.2.5
@angular/common: 4.2.5
@angular/compiler: 4.2.5
@angular/compiler-cli: 4.2.5
@angular/core: 4.2.5
@angular/forms: 4.2.5
@angular/http: 4.2.5
@angular/platform-browser: 4.2.5
@angular/platform-browser-dynamic: 4.2.5
@angular/platform-server: error
@angular/router: 4.2.5
@angular/tsc-wrapped: 4.0.3
@angular/upgrade: error
@angular/cli: 1.2.0
C:\NG\projectName\app\components>npm -v
3.10.10