How do I run Angular.JS 2 for TypeScript on C9.io on port 8080?

痞子三分冷 提交于 2020-01-03 03:09:08

问题


I followed this quick tutorial: https://angular.io/guide/quickstart and build the code on C9.io, but by default it's trying to run on port 3000, and C9.io only allows using ports 8080, 8081, and 8082. So how can I run it on C9.io?

Here's my code: https://ide.c9.io/mathieu_roy/angular2-quickstart


回答1:


I was dealing with the same issue, instead of creating a bs-config.json which will be discoverable automatically you can create a bs-config.js which will also be discoverable by default and be used. Place the bs-config.js file in the root directory.

//bs-config.js
module.exports = {
    port: process.env.PORT,
        files: [ './**/*.{html,htm,css,js}' ],
        server: {
        baseDir: "./"
   }
};

now you can use c9 environment variables like process.env.PORT




回答2:


You can change the lite npm script to invoke lite-server with a custom configuration including port.

{
  "port": 8000,
  "files": ["./src/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./src" }
}

More

https://github.com/johnpapa/lite-server#custom-configuration



来源:https://stackoverflow.com/questions/37104588/how-do-i-run-angular-js-2-for-typescript-on-c9-io-on-port-8080

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!