Do you want to request a feature or report a bug?
BUG
What is the current behavior?
I have a working npm project.
When migrating to yarn (yarn to create a yarn.lock) it's broken.
If the current behavior is a bug, please provide the steps to reproduce.
"dependencies": {
"react": "^15.4.1",
"react-native": "0.39.0",
"react-native-text": "^0.0.4",
"react-redux": "^4.4.6",
"redux": "^3.6.0",
"redux-logger": "^2.7.4",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-jest": "^17.0.0",
"babel-preset-react-native": "1.9.0",
"deep-freeze": "^0.0.1",
"enzyme": "^2.6.0",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jest": "^1.0.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.6.0",
"jasmine-reporters": "^2.2.0",
"jest": "^17.0.3",
"jest-react-native": "^17.0.3",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
"react-test-renderer": "^15.4.1",
"redux-mock-store": "^1.2.1",
"whatwg-fetch": "^2.0.1"
},
rm -rf node_modules
(to omit side effects).npm install
, running react-native *
(let * be any react-native command) works fine.yarn
creates a yarn.lock as expected. But when running react-native *
it fails with Error: Cannot find module './assets/empty-module.js'
module.js:341
throw err;
^
Error: Cannot find module './assets/empty-module.js'
at Function.Module._resolveFilename (module.js:339:15)
at Function.require.resolve (internal/module.js:23:19)
at Object.<anonymous> (/PATH/TO/MY/PROJECT/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/ResolutionRequest.js:20:29)
at Module._compile (module.js:413:34)
at loader (/PATH/TO/MY/PROJECT\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/PATH/TO/MY/PROJECT\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
1. HINT: I get the same when NOT using npm at all. So starting with a clean directory and yarn install.
2. HINT: I first got this issue when updating my dependency versions from an older version using yarn only!
3. HINT: I post this issue here as there is no problem when using npm (as of today). So I don't think it's a problem with react-native.
What is the expected behavior?
Running yarn does not screw up my dependencies.
Please mention your node.js, yarn and operating system version.
The bug is also reproducible with:
I encountered this issue as well. My hot fix is to touch an empty file for empty-module.js
.
__Updates__:
According to #832, you may check whether your .yarnclean containing a line assets
. If yes, delete that line and do rm -rf node_modules && yarn
to see if this fixes your issue. This helped me.
Thanks a lot!
This actually worked for us.
We should have read yarn clean
's disclaimer earlier:
Note: This command is considered for advanced use cases only. Unless you are experiencing
issues with the amount of files that are installed as part of node_modules it is not
recommended to use this command. It uses a heuristic to identify files that may not be
needed from a distributed package and may not be entirely safe.
Unfortunately yarn clean
and the .yarnclean
worked for us without any problem when using react-native 0.37.x.
I'm hitting the same error after I ran yarn clean
on RN 0.41.2. Thanks @peteroid for the workaround, but this should get a proper fix without such workaround.
Reopen this issue?
@fungilation I recommend not using the workaround (touch empty-module.js). See peteroid's update and my comment: You should take care about the yarn clean
and your .yarnclean
, because it uses a heuristic to identify files
, so it may find false positives.
The fix I find working is peteroid's update, not touching the file.
According to #832, you may check whether your .yarnclean containing a line assets. If yes, delete that line and do rm -rf node_modules && yarn to see if this fixes your issue. This helped me.
I ended up removing my .yarnclean file (which was way overgeneralized), removed node_modules, then ran yarn
again. Seems to have been fixed. I don't recall calling yarn clean
on my project, but it got to the point where once I added a new dependency, it just broke everything. All my graphical assets inside my node_modules were erased.
rm -rf node_modules && yarn
was enough for me FYI
Most helpful comment
I encountered this issue as well. My hot fix is to touch an empty file for
empty-module.js
.__Updates__:
According to #832, you may check whether your .yarnclean containing a line
assets
. If yes, delete that line and dorm -rf node_modules && yarn
to see if this fixes your issue. This helped me.