Core: Error loading ng2-translate.js in angular2 final release

Created on 5 Oct 2016  ·  19Comments  ·  Source: ngx-translate/core

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]

Most helpful comment

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 https://github.com/ocombe/ng2-translate/issues/251

All 19 comments

+1

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 https://github.com/ocombe/ng2-translate/issues/251

@dhardtke You saved my day!

I had the same error, thank you!

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!

@dhardtke You saved my day either!

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?

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

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

@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.

@unsafePtr
Thanks, it works for me.

@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.

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 ?

@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....

Navigate this for information. Just my another thought.

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

Missed this thread. More information in here https://github.com/ocombe/ng2-translate/issues/219#issuecomment-256256623.

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?

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IterationCorp picture IterationCorp  ·  3Comments

jellene4eva picture jellene4eva  ·  3Comments

chris31389 picture chris31389  ·  3Comments

pndewit picture pndewit  ·  3Comments

briancullinan picture briancullinan  ·  3Comments