angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build

Open englishandy opened this issue 9 years ago • 9 comments

I installed a clean angular cli "hello world" project, local host works fine, but when i build it doesn't work in production.

Can you explain if i need to change anything out of the box to just get a working prod version that is able run (the prod server is not running nodejs..but i dont need it right?).

i tried ng build and copied the filed over to the server manually as i dont have environments setup.

englishandy avatar Dec 09 '16 14:12 englishandy

Please reproduce #3495 to see if your issue is a duplicate of it or not.

nweldev avatar Dec 09 '16 15:12 nweldev

OS? Windows 7

Versions. angular-cli: 2.1.0 node: 6.9.1 os: win32 x64

-- Where do i put the dev mode script?(sorry new to this)

if (isDevMode()) { console.log('devmode'); } @NgModule({ declarations: [AppComponent], imports: [ BrowserModule, HttpModule ], bootstrap: [AppComponent] }) export class AppModule { }

englishandy avatar Dec 09 '16 15:12 englishandy

My bad, I wanted to say "check", not reproduce ... if you didn't use isDevMode and didn't change anything about environment.prod.ts, this is not a duplicate. But we still need some infos ... Please follow the Submission Guidelines

nweldev avatar Dec 09 '16 15:12 nweldev

OS? Windows 7

Versions. angular-cli: 2.1.0 node: 6.9.1 os: win32 x64

Repro steps. Create an app using CLI start the app in localhost - ng serve (works fine) build app - ng build (also tried ng build --prod) - produces the following files in "dist" folder.. favicon.ico index.html inline.bundle.js inline.map main.bundle.js main.map styles.bundle.js styles.map nothing else, so when i upload this to live server it display "loading..." only.

englishandy avatar Dec 09 '16 16:12 englishandy

in the prod environment i see "loading", and error in the console

SyntaxError: in strict mode code, functions may be declared only at top level or immediately within another function http://mydomain.com/main.bundle.js Line 45364

englishandy avatar Dec 09 '16 16:12 englishandy

I don't think this is an issue with angular-cli. See http://stackoverflow.com/questions/24573061/uncaught-syntaxerror-in-strict-mode-code-functions-can-only-be-declared-at-top and check your code. If you still don't find anything, give use the lines of code around the error.

nweldev avatar Dec 09 '16 18:12 nweldev

Dupe of https://github.com/angular/angular/issues/13301

hansl avatar Dec 09 '16 18:12 hansl

I know this is after the fact, but I got it to work by putting the contents of the dist folder (excepting the index.html) into the root folder of the production site...it seems that's where angular is looking for them. Is there a way to build so that the bundles do not have to be placed directly in the root? This could get quick messy if running multiple angular apps on the same site.

UPDATE: I was able to get this to work by using the --base-href /MyUrl/ during the ng build (documented in README)

iTrout avatar Dec 14 '16 05:12 iTrout

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.