Core: Error: XHR error (404 Not Found) loading .. /ng2-translate/ng2-translate

Created on 31 Mar 2016  路  9Comments  路  Source: ngx-translate/core

I think I followed the direction in README.md, but I got this error.
It could be very tiny mistake that I made, but I could not figure it out.

image

http://plnkr.co/edit/ntq01S?p=preview

Any help would be appreciated with the example given

Most helpful comment

I could finally make it work. I am using angular cli and had to edit system-config.ts and add
const map: any = {
'ng2-translate': 'vendor/ng2-translate'
};

/** User packages configuration. */
const packages: any = {
'ng2-translate': {
defaultExtension: 'js'
}
}

and in angular-cli-build.js I added the file in vendorNpmFiles, so it is copied in dist
'ng2-translate/*_/_.js'

All 9 comments

FYI, This is the bundle script that I used

    <script src="https://rawgit.com/ocombe/ng2-translate/master/bundles/ng2-translate.js"></script>

Same issue here. Renders the library useless as it crashes immediately on this. Any one else seeing this?

Hi,
Localy when you use npm instead of CDN you still got the same error?
Via npm I can't reproduce this. Can you reproduce this with Angular2 >= beta15?

I am using beta 15 and I have the same problem:

In app.ts, TS compiles,
import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader,
TranslateStaticLoader} from 'ng2-translate/ng2-translate';

index.html

then in browser I get
http://localhost:4200/ng2-translate/ng2-translate.js 404 (Not Found)
angular2-polyfills.js:390 Error: Error: XHR error (404 Not Found) loading http://localhost:4200/ng2-translate/ng2-translate.js

I have had similar problem. You are probably missing mapping ng2-translate to node_modules/ng2-translate or other folder where your ng2-translate is located.

Here is my systemjs.config.js
Look at my map section.

https://gist.github.com/VsMaX/214688cee7ff58989fab72948fe80b00

I could finally make it work. I am using angular cli and had to edit system-config.ts and add
const map: any = {
'ng2-translate': 'vendor/ng2-translate'
};

/** User packages configuration. */
const packages: any = {
'ng2-translate': {
defaultExtension: 'js'
}
}

and in angular-cli-build.js I added the file in vendorNpmFiles, so it is copied in dist
'ng2-translate/*_/_.js'

After updating system-config.ts as @gc392 mentioned,

In angular-cli-build.js I added the file in vendorNpmFiles:
'ng2-translate/**/*.js'

this is successful
thanks @rgajam and @gc392

system-config.ts
const map: any = {
'ng2-translate': 'vendor/ng2-translate'
};

/** User packages configuration. */
const packages: any = {
'ng2-translate': { defaultExtension: 'js' }
};

in angular-cli-build.js
'ng2-translate/*_/_.js'

Closing this old issue, let me know if I should reopen it.

Was this page helpful?
0 / 5 - 0 ratings