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

2019-06-02 11:03发布

问题:

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