0

Im using the latest version of angular-cli. If I understood rightly, I can use ng build to obtain a compiled project in a js representation. In a /dist folder, according to documentation by default.

Im new with JS, so I simply cant understand how can I launch the project...

Command works fine, and I can find a bunch of files in a folder, but how can I launch a project as expected (like it was in a dev mode with ts-files)? I mean simply launching index.html just shows me a "Loading.." text, but application doesnt launch how it was expected.

Help please. Thanks!

4 Answers 4

2

Even if you get the app to run from a file, with messing base href etc, some things might not work (maybe AJAX, etc).

The dist folder is meant to be used with a server.

If you want to just browse the app, regardless of the files, you can run ng serve, which will serve the app in-memory (for speed) at http://localhost:4200, and will sit and watch for changes, and update the page when you make them.

When you are done developing, you run ng build, and take the contents of the dist folder to your server.

Sign up to request clarification or add additional context in comments.

Comments

1

You would need a webserver. Just copy the contents of the /dist folder to a webserver root and you're ready to go.

What is your goal? Ng build is meant to create a distributable version of your app, ng serve is meant for local development.

4 Comments

Just found an answer: stackoverflow.com/questions/37558656/…. I needed to add a dot here in index.html <base href="./">. Thanks for attention, Mike!
Mike, sorry its out of topic, but maybe u can help.. So Im going to using DigitalOcean (with dedicated Ubuntu) to launch this app remotely. What am I going to do is to open this essential index.html through node.js which I had already installed. It should works, but maybe there is a more common and better solution?
Maybe it is better to start a new question with some more specifics about what you're teying to achieve?
@Michael thanks for the comment. your dot saved my day. :)
1

Execute this command

ng build -prod

Also set in the environments/environment.ts file, the property "production":true

export const environment = {
  production: true
};

That will create a dist folder, ready to deploy

Comments

0

There is new angular-cli tool, install that

Perform these one by one...

npm uninstall -g angular-cli
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli

I completely removed the node_modules directory (rm -rf node_modules dist), Generate a new project and compare files like your package.json, angular-cli.json by ng new temp Compare & Changed the package.json to match the "dependencies" and "devDependencies". Fixed the angular-cli.json file for changes in the environment configs.

run ng serve after the npm install

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.