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

时间:2017-06-14 09:51:29

标签: angular deployment browser-sync lite-server

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

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

  

'网站需要很长时间才能回复'

来自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,因为lite-server试图打开我不想要的浏览器。

{
  "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机器上运行时,一切正常,但实际上文件也显示在控制台中。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

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

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