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

Error loading ng2-translate.js in angular2 final release #270

Closed
MrHOY opened this issue Oct 5, 2016 · 19 comments
Closed

Error loading ng2-translate.js in angular2 final release #270

MrHOY opened this issue Oct 5, 2016 · 19 comments

Comments

@MrHOY
Copy link

MrHOY commented Oct 5, 2016

I'm submitting a ... (check one with "x")

[x ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[x ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Reproduction of the problem
I have problem with ng2-translate lastest (3.0.1)
When I make example quickstart angular2 , then I import ng2-translate set up like README and I see error

Failed to load resource: the server responded with a status of 404 (Not Found)

I go to console log in index.html and see:
error

Please tell us about your environment:

  • ng2-translate version: 3.0.1
  • Angular version: 2.0.1 final release
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]
@andreivirtosu
Copy link

+1

@dhardtke
Copy link
Contributor

dhardtke commented Oct 6, 2016

Try to set config.paths in your SystemJS config to this object:

paths:    {
    "ng2-translate/ng2-translate": "node_modules/ng2-translate/bundles/ng2-translate.js"
    }

See #251

@yoldar
Copy link

yoldar commented Oct 8, 2016

@dhardtke You saved my day!

@ivancalva
Copy link

I had the same error, thank you!

@MrHOY
Copy link
Author

MrHOY commented Oct 20, 2016

or you can set in SystemJS:

map: {
'ng2-translate': 'npm:ng2-translate/bundles/ng2-translate.js'
}
packages: {
'ng2-translate': {
defaultExtension: 'js'
}
}

It work for me! Thanks all!

@huyaxiong
Copy link

@dhardtke You saved my day either!

@unsafePtr
Copy link

unsafePtr commented Oct 25, 2016

I have been looking for another issues with the same problem and ways to resolve it, but didn't find a way.
So exception is:

(index):29 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:57462/traceur.js(…)

And i was uisng below code in systemjs.config.js:

'ng2-translate': 'npm:ng2-translate'

I am using v3.1.3 of package and Typescript v.2.0.3.
The solution one post above advice to provide another path to file:

'ng2-translate': 'npm:ng2-translate/bundles/ng2-translate.js'

But in my folder doesn't exist such file. In this folder exists another files: index.js, indexd.ts and ng2-translate.d.ts.

I'm totally destroyed with the error. Can anyone help me?

@ocombe
Copy link
Collaborator

ocombe commented Oct 25, 2016

You should just use 'ng2-translate': 'ng2-translate'

@ocombe
Copy link
Collaborator

ocombe commented Oct 25, 2016

Or if you really need the full path, you can use 'ng2-translate': 'ng2-translate/bundles/index.js'

@unsafePtr
Copy link

unsafePtr commented Oct 25, 2016

@ocombe Hi, i fixed it before five minutes:
In map section:

'ng2-translate': 'npm:ng2-translate'

In packages section:

"ng2-translate": {
main: "bundles/index.js",
defaultExtension: "js"
}

File was successfully uploaded, but error doesn't remain. Seems it was fired by another item/package.
Thanks for very fast answer 👍 Have a nice day.

@ortichon
Copy link

@unsafePtr
Thanks, it works for me.

@unsafePtr
Copy link

unsafePtr commented Oct 25, 2016

@ortichon @ocombe,
Just understood now that it doesn't works for me. Traceur error continued, and it is fired by ng2-translate.
Helped to remove "catch" from System.import in index file

System.import('appTS/main');

Then i received much more helpful exception.
error
And i didn't know how to proceed now. I already spend about 4 hours for this error and it is not resolved. Hope my experience was helpful for someone.

@ocombe
Copy link
Collaborator

ocombe commented Oct 25, 2016

If you get a traceur error, it's that it tries to load typescript files instead of compiled js files (and since you didn't install traceur it doesn't work).
I wonder if it's because of the type definition files in the bundles folder ? Maybe systemjs tries to load them at the same time ?

@unsafePtr
Copy link

unsafePtr commented Oct 25, 2016

@ocombe I have some installed package which name is ng2-ckeditor. SystemJs successfully upload its js file without any errors. The definition in my config for this package:
'ng2-ckeditor': 'npm:ng2-ckeditor'
"ng2-ckeditor": { main: "lib/index.js", defaultExtension: "js", }
The folder "lib" in ng2-ckeditor contains index.d.ts and index.js too.

May be for some reason SystemJs get confused and getting to transiple ng2-translate.js file....

@unsafePtr
Copy link

Navigate this for information. Just my another thought.

@unsafePtr
Copy link

Fixed it with changing import path in components from "ng2-translate/ng2-translate" to "ng2-translate".

@SamVerschueren
Copy link
Collaborator

Missed this thread. More information in here #219 (comment).

@dawud-do
Copy link

I get

 26 10 2016 09:14:50.238:WARN [web-server]: 404: /base/node_modules/ng2-translate.js
 26 10 2016 09:14:50.286:WARN [web-server]: 404: /base/node_modules/lodash.js
 PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR: '(SystemJS) XHR error (404 Not Found) loading http://localhost:9876/base/node_modules/ng2-translate.js
    Error loading http://localhost:9876/base/node_modules/ng2-translate.js as "ng2-translate" from http://localhost:9876/base/dist/dev/app/app.component.js'

when running karma test of an angular2 seed base. the suggestions in here haven't been working for me. for instance if I include path to bundles in my config.ts I just get a new error saying it can't find that.
my karma baseURL is set to /base/ and my app.component.ts imports from 'ng2-translate'

any clue where I might want to look?

@ocombe
Copy link
Collaborator

ocombe commented Nov 3, 2016

@dawud-do please check the other issues, multiple solutions to these problems have been given.

@ocombe ocombe closed this as completed Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests