部署 Angular 2 个应用程序(没有 angular-cli)

Deploying Angular 2 application (without angular-cli)

我正在尝试从我的 Linux 服务器部署我的应用程序。

除了我的 lite-server 命令没有提供任何文件外,一切正常。在 serverUrl:3000 访问我的服务器会抛出一个

'site takes too long to respond'

我的脚本来自 package.json(我 运行 npm start

"scripts": {
    "build": "tsc -p src/",
    "serve": "lite-server -c=bs-config.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "test-once": "karma start karma.conf.js --test-once",
    "pretest:once": "npm run build",
    "build:watch": "tsc -p src/ -w",
    "build:upgrade": "tsc",
    "serve:upgrade": "http-server",
    "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
    "serve:aot": "lite-server -c bs-config.aot.json",
    "build:babel": "babel src -d src --extensions \".es6\" --source-maps",
    "copy-dist-files": "node ./copy-dist-files.js",
    "i18n": "ng-xi18n",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },

我的bs-config.json。我必须添加 "open" : false,因为精简版服务器试图打开我不想要的浏览器。

{
  "server": {
    "baseDir": "src",
    "routes": {
      "/node_modules": "node_modules"
    }
   }, "open" : false
}

此命令的输出如下:

> angular-io-example@1.0.0 prestart /home/deploy/home/deploy/frontend
> npm run build


> angular-io-example@1.0.0 build /home/deploy/home/deploy/frontend
> tsc -p src/


> angular-io-example@1.0.0 start /home/deploy/home/deploy/frontend
> concurrently "npm run build:watch" "npm run serve"

[0]
[0] > angular-io-example@1.0.0 build:watch /home/deploy/home/deploy/frontend
[0] > tsc -p src/ -w
[0]
[1]
[1] > angular-io-example@1.0.0 serve /home/deploy/home/deploy/frontend
[1] > lite-server -c=bs-config.json
[1]
[1] ** browser-sync config **
[1] { injectChanges: false,
[1]   files: [ './**/*.{html,htm,css,js}' ],
[1]   watchOptions: { ignored: 'node_modules' },
[1]   server:
[1]    { baseDir: 'src',
[1]      middleware: [ [Function], [Function] ],
[1]      routes: { '/node_modules': 'node_modules' } },
[1]   open: false }
[1] [BS] Access URLs:
[1]  ----------------------------------------
[1]        Local: http://localhost:3000
[1]     External: http://serverurl:3000
[1]  ----------------------------------------
[1]           UI: http://localhost:3001
[1]  UI External: http://serverurl:3001
[1]  ----------------------------------------
[1] [BS] Serving files from: src
[1] [BS] Watching files...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[1] [BS] Reloading Browsers...
[0] 9:42:13 AM - Compilation complete. Watching for file changes.

当我在我的 Windows 机器上 运行 时一切正常,但文件实际上也在控制台中显示。有什么想法吗?

原来我的防火墙阻止了端口。

打开端口解决了问题(ufw allow 3000)