gpt4 book ai didi

javascript - Angular : ng build fails but npm run build works fine

转载 作者:行者123 更新时间:2023-11-30 08:23:27 25 4
gpt4 key购买 nike

在我的 Angular 5 应用程序中,我有 angular-cli 1.6.8

{
"name": "test",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"karma": "ng test",
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --runInBand",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.7",
"@angular/common": "^5.2.7",
"@angular/compiler": "^5.2.7",
"@angular/core": "^5.2.7",
"@angular/forms": "^5.2.7",
"@angular/http": "^5.2.7",
"@angular/platform-browser": "^5.2.7",
"@angular/platform-browser-dynamic": "^5.2.7",
"@angular/platform-server": "^5.2.7",
"@angular/router": "^5.2.7",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"lodash": "^4.12.0",
"moment": "^2.18.1",
"npm": "^5.2.0",
"proxy-polyfill": "^0.1.7",
"rxjs": "^5.5.6",
"sha1": "^1.1.1",
"smoothscroll-polyfill": "^0.3.5",
"web-animations-js": "^2.2.5",
"zone.js": "^0.8.8"
},
"devDependencies": {
"@angular/cli": "1.6.8",
"@angular/compiler-cli": "^5.2.7",
"@types/jasmine": "2.5.38",
"@types/jest": "^20.0.5",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"jest": "^20.0.4",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-jest": "^20.0.7",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "2.6.2"
},
}

在我的应用程序文件夹中运行 ng --version 或 ng build 时,它没有提示:bash: ng: command not found -> 相反运行 npm run build 正常运行

我在全局安装了 node 8.0.0npm 4.2.2,但我没有在全局安装 angular-cli,我不'想安装它。因此我认为我可以在我的应用程序中(本地)使用 ng 命令,不是吗?

如果不是,我怎么能不通过 npm install -g @angular/cli 全局安装它呢 (因为我不允许运行全局 npm install 操作)

建议?

最佳答案

如果你想使用 ng 命令以及其他命令,你需要全局安装它们。您无法运行本地命令,因为 NodeJS 找不到它们。

关于javascript - Angular : ng build fails but npm run build works fine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49751646/

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