GIT存储库中有一个角度项目。我想从原始系统(Mac OS-X Mojave 10.14.6)克隆它,安装所需的任何Angular组件,然后继续进行项目开发,但似乎无法使开发环境正常工作。 >
npm版本6.10.2 节点版本10.16.2
我克隆存储库并使用bash,使用package.json导航到目录。
$npm install
$ng serve
-bash:/ usr / local / bin / ng:没有这样的文件或目录
据我了解, npm install 应该安装我需要的任何东西。
这是我的package.json的内容。
{
"name": "ng-dsl-edit",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.1.1",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/material": "^7.1.1",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
"ace-diff": "^2.3.0",
"core-js": "^2.5.4",
"diff-match-patch-ts": "^0.2.0",
"hammerjs": "^2.0.8",
"ngx-diff": "^0.1.1",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.6",
"@angular/compiler-cli": "^8.2.8",
"@angular/language-service": "~7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.3.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
}
}
答案 0 :(得分:2)
您可以使用npm start
代替ng serve
。
为什么会这样?
因为在您的环境中全局范围内没有ng
,所以您会收到该错误。您还可以运行npm install -g @angular/cli
使其在全局范围内可用。
npm start
为什么起作用?
在package.json
内部,您可以看到script
块中有一些命令。这样,nodejs将在本地范围(在文件夹node_modules/.bin
中)找到二进制文件,您已经运行了npm install
,因此ng
将在本地范围内可用。
希望有帮助!
答案 1 :(得分:0)
您需要全局安装Angular cli。
npm install -g @angular/cli
或
npm install -g @angular/cli@7.X
看到您有7个项目