Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng build #3496

Closed
englishandy opened this issue Dec 9, 2016 · 9 comments
Closed

ng build #3496

englishandy opened this issue Dec 9, 2016 · 9 comments

Comments

@englishandy
Copy link

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.

@nweldev
Copy link
Contributor

nweldev commented Dec 9, 2016

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

@englishandy
Copy link
Author

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 { }

@nweldev
Copy link
Contributor

nweldev commented Dec 9, 2016

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

@englishandy
Copy link
Author

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
Copy link
Author

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

@nweldev
Copy link
Contributor

nweldev commented Dec 9, 2016

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.

@hansl
Copy link
Contributor

hansl commented Dec 9, 2016

Dupe of angular/angular#13301

@hansl hansl closed this as completed Dec 9, 2016
@iTrout
Copy link

iTrout commented Dec 14, 2016

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)

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants