1

I am using angular cli for my angular 2 application. After npm run build, dist folder is created. When I open index.html of dist folder, it cannot find files like inline.bundle.js, polyfills.bundle.js etc. I need to give an absolute path for these files so that I can run my project. Please help.

10
  • 1
    In order to build angular cli project, you should run ng build command. Commented Jul 21, 2017 at 5:46
  • @Darshita I have built the project. The relative path of mentioned files are the issue. Commented Jul 21, 2017 at 5:50
  • Have you published your dist folder? Commented Jul 21, 2017 at 5:54
  • @Darshita not really. Can you please elaborate? Commented Jul 21, 2017 at 5:58
  • 1
    possibly your problem related with base href. check the cli --base-href option Commented Jul 21, 2017 at 6:09

2 Answers 2

2

TO RESOLVE THIS ISSUE OF PROVIDING THE ABSOLUTE PATH

Please use the command below to generate the build of project using angular cli

Command for the dev build

ng build --base-href ./

for the production build

ng build --prod --base-href ./

Base-href is used to notify the path of js file located at.

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

5 Comments

core.es5.js:1020 ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/keshavdhawan/Documents/sd/dist/' cannot be created in a document with origin 'null' and URL 'file:///Users/keshavdhawan/Documents/sd/dist/index.html'. Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/keshavdhawan/Documents/sd/dist/' cannot be created in a document with origin 'null' and URL 'file:///Users/keshavdhawan/Documents/sd/dist/index.html'.
This one. ng build --base-href ./
I have also run this command its working fine in my case please. is that the error that you are getting in console or terminal. please try to run that command from the root directory
On terminal it is building fine. I am getting this error on console when I open index.html of dist folder.
And its just on chrome and firefox. I tested on safari, its working fine. May be a security issue.
1

I used this and working fine:

ng build --base-href 'SERVER_APPLICATION_PATH'

LIKE AS

ng build --base-href 'http://localhost/web/angular-first/'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.