AlexanderZaytsev/react-native-i18n

i18n-js dependency missing

VinceBT opened this issue · 13 comments

Since 2.0.0 I've got this error while running the packager, I've clean cached and tried to reinstall all dependencies multiple times

error: bundling: UnableToResolveError: Unable to resolve module `i18n-js` from `C:\XXX\node_modules\react-native-i18n\index.js`: Module does not exist in the module map or in these directories: C:\XXX\node_modules

Temporary fix : npm install -S i18n-js

EDIT: Use npm install fnando/i18n-js#v3.0.1

@VinceBT What package manager are you using?
This problem is tied to i18n-js, which is not available on npm

The npm package is https://www.npmjs.com/package/i18n-js
https://github.com/everydayhero/i18n-js

Currently using npm v5
It is available on npm since I managed resolved the problem by using npm install -S i18n-js
I think npm just does not understand the dependency here in your package.json and so it does nothing

"dependencies": {
    "i18n-js": "github:fnando/i18n-js#v3.0.0"
}

@VinceBT It is available on npm, but this an old version, check the README: https://github.com/everydayhero/i18n-js

Yes maybe but the issue is still here

@VinceBT Have you tried npm start --reset-cache to start the packager? It fix the issue for me.

npm understand this kind of dependency format actually: https://docs.npmjs.com/files/package.json#github-urls
If you try npm install fnando/i18n-js#v3.0.0 on npm 5, it will add exactly this to the package.json, so it looks like a npm cache issue. Yarn doesn't seem concerned.

I've told that I've tried all the cache solutions.
Try to delete node_modules folder and then do npm i and you'll see that the package does not install on npm 5.
PS : The actual command is npm start -- --reset-cache either npm does not pass the argument to the packager.
PS2 : I'm starting to think that this is an issue of NPM that does not initialize Git dependencies of sub-dependencies of a project.

@VinceBT I see. It was fixed not because of the cache, but because I've made an npm install in the root folder.

I check the npm issues like you said, and it is already reported (and the error occurs even with no lockfile):
npm/npm#17405
npm/npm#17365

Possible fixes: npm install fnando/i18n-js#v3.0.1 (instead of the obsolete version on npm), or maybe consider switching to yarn ?

I'm switching to yarn temporarily but I had hope that npm finally caught up with Yarn :p
Going to +1 your answer with the fix so anyone can see

@VinceBT Thanks, I keep this issue opened until npm fixes this.
I edited the readme.md.

Is this still relevant?

i18n-js@3.0.1 seems to be on npm since August

@AlexanderZaytsev @zoontek can you try it and, if it works, update the dependency please ?

@VinceBT Done, thanks

It's ok when I change to 5.5.1