我是角色新手6我已经从link
下载了现成的角度模板导航到根文件夹&已执行npm install
尝试运行应用ng serve
,但显示错误
无法找到本地工作区文件(' angular.json')。
的package.json
{
"name": "angular-6-registration-login-example",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/cornflourblue/angular-6-registration-login-example.git"
},
"scripts": {
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"license": "MIT",
"dependencies": {
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"core-js": "^2.5.5",
"rxjs": "^6.1.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@types/node": "^10.0.4",
"angular2-template-loader": "^0.6.2",
"html-webpack-plugin": "^3.2.0",
"raw-loader": "^0.5.1",
"ts-loader": "^4.3.0",
"typescript": "^2.8.3",
"webpack": "4.8.1",
"webpack-cli": "^2.1.3",
"webpack-dev-server": "3.1.4"
}
}
我的环境配置是,
Angular CLI: 6.0.3
Node: 8.11.2
OS: linux x64
Angular: 6.0.3
... common, compiler, core, forms, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.3 (cli-only)
@angular-devkit/core 0.6.3 (cli-only)
@angular-devkit/schematics 0.6.3 (cli-only)
@schematics/angular 0.6.3 (cli-only)
@schematics/update 0.6.3 (cli-only)
rxjs 6.2.0
typescript 2.8.4
webpack 4.8.1
请帮我解决这个问题。
答案 0 :(得分:2)
由于您的项目不使用Angular-CLI,因此无法执行导致错误的ng serve
,因为ng serve
会查找此配置文件以启动您的应用
找不到本地工作区文件('angular.json')。
它使用webpack
,所有webpack
配置都存储在webpack.config.js中。
如果你观察你的package.json,你可以在脚本部分start
和build
"scripts": {
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
您可以使用npm
执行这些脚本
执行npm run start
以进行开发构建
答案 1 :(得分:0)
如果您阅读package.json。未安装angular/cli
,因此运行ng serve
将无效。
package.json文件显示以下命令,您应该运行它npm start
:
"scripts": {
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
}
答案 2 :(得分:0)
收到此错误消息后,我运行了“ npm install”,我的项目获得了所有模块,并且运行了。
答案 3 :(得分:-1)
我一直在使用angular 6最新版本,但使用的Proyect版本为1.6.8,我无法运行ng serve,因为出现错误,无法找到angular.json。
这是package.json
{
"name": "mktools2.0",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.2",
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.2",
"@ngu/carousel": "^1.4.8",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "1.6.8",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}