【发布时间】:2017-10-16 01:06:39
【问题描述】:
我正在尝试将我的 Angular 4 应用程序部署到 heroku,但我遇到了诸如找不到“ng 命令”之类的错误。 我猜测我需要更改 package.json 中的某些内容以强制它安装 CLI,但我无法让它工作。
这是 package.json:
{
"name": "q",
"version": "0.0.0",
"license": "MIT",
"watch": {
"run-watch": {
"patterns": [
"src",
"server",
"e2e"
],
"extensions": "js,ts,css,scss,html"
}
},
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build && node server/server.js",
"run-watch": "ng build && node server/server.js",
"lint": "ng lint",
"e2e": "ng e2e",
"watch": "npm-watch"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.1.2",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/material": "^2.0.0-beta.4",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"axios": "^0.16.1",
"body-parser": "^1.17.1",
"core-js": "^2.4.1",
"express": "^4.15.2",
"hammerjs": "^2.0.8",
"morgan": "^1.8.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.3",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.5.2",
"npm-watch": "^0.1.9",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
这是我在 npm start 期间收到的消息:
npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! q@0.0.0 start: `ng serve`
npm ERR! spawn ENOENT
如何让 cli 在服务器上运行?
【问题讨论】:
-
需要全局安装 CLI 才能使用类似的命令。请改用
npm start。 -
错误:“@angular/compiler-cli”包没有正确安装。
-
通过将编译器 CLI 移至dependencis 使其工作。
-
也许 Heroku 没有安装
devDependencies。 -
我会搜索更多,但这是可能的。它应该是服务器而不是开发环境。 :)
标签: json node.js angular heroku