【问题标题】:Error in package.json deploying Angular2 project on Azure using bitbucketpackage.json 使用 bitbucket 在 Azure 上部署 Angular2 项目时出错
【发布时间】:2017-03-03 09:20:00
【问题描述】:

我在 azure 上部署 angular2 应用程序时遇到问题。我在以下行出现错误

"engines":{"node":"6.2.1"},

我给出了这个版本,因为 WEBSITE_NODE_DEFAULT_VERSION 的值为 6.2.1。任何对此有想法的人请分享。

这是错误快照:

package.json 如下:

{
"name": "angular-quickstart",
"version": "1.0.0",
"engines":{"node":"6.2.1"},
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"docker-build": "docker build -t ng2-quickstart .",
"docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
"pree2e": "npm run webdriver:update",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/*/.ts -t verbose",
"lite": "node_modules\.bin\lite-server",
"postinstall": "typings install",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "node_modules\.bin\tsc",
"concurrently": "node_modules\.bin\concurrently",
"tsc:w": "node_modules\.bin\tsc -w",
"typings": "node_modules\.bin\typings",
"webdriver:update": "webdriver-manager update"
},
"keywords": [],
"author": "",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
"@angular/upgrade": "~2.1.0",

"angular-in-memory-web-api": "~0.1.5",
"bootstrap": "^3.3.7",
"systemjs": "0.19.39",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings": "^1.4.0"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings": "^1.4.0",

"canonical-path": "0.0.2",
"http-server": "^0.9.0",
"tslint": "^3.15.1",
"lodash": "^4.16.2",
"jasmine-core": "~2.5.2",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-htmlfile-reporter": "^0.3.4",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^3.3.0",
"rimraf": "^2.5.4"
},
"repository": {}
}

请提出解决方案。

【问题讨论】:

标签: node.js azure angular bitbucket package.json


【解决方案1】:

当您在服务器或云端部署应用时,您应该在 process.env.PORT 提供的端口上运行它,以下是一个示例:

app.listen(process.env.PORT || 3000, () => {
  console.log('Example app is running!');
});

在您的 package.json 文件中,启动脚本将应用程序设置为默认在端口 3000 上运行。

【讨论】:

  • 我应该在哪里添加此代码?和node版本相关的错误呢?
  • 我还没有部署过 Angular 2 应用程序,但是您可以在网上找到许多说明来帮助您了解如何让您的应用程序为生产做好准备。
  • 顺便说一下,我认为这个文件 protractor.conf.js 是涉及的,它包含你的应用程序的基本 URL。
  • 好的。将尝试它,但如何摆脱 package.json 中节点引擎上的错误
  • 尝试通过设置入口文件(如 app.js)来设置静态节点服务器来为您的应用程序(如 MEAN 应用程序)提供服务。
【解决方案2】:

来自 Angular js2 纪录片:

If Node.js and npm aren't already on your machine, install them. Our examples require node v4.x.x or higher and npm 3.x.x or higher. To check which version you are using, run node -v and npm -v in a terminal window.

能否请您检查一下您的 npm 版本?

【讨论】:

  • 我安装了 node 版本 node 版本 6.3.1 和 npm 版本 3.10.3
  • :D 你能提供你的错误信息吗?我记得你给了它,但我现在看不到它。
猜你喜欢
  • 2021-01-19
  • 1970-01-01
  • 1970-01-01
  • 2011-08-24
  • 1970-01-01
  • 1970-01-01
  • 2017-06-20
  • 1970-01-01
  • 2021-12-26
相关资源
最近更新 更多