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

2019-06-02 11:20发布

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

2条回答
我命由我不由天
2楼-- · 2019-06-02 11:40

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

查看更多
Luminary・发光体
3楼-- · 2019-06-02 11:55

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

查看更多
登录 后发表回答