Bundler looks in directories besides node_modules for node_modules
See original GitHub issueyarn
mv node_modules xxx
yarn
yarn react-native start
# load app in a simulator
This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
Duplicate module name: react-animated
Paths: /path/to/my/project/node_modules/react-native/Libraries/Animated/release/package.json collides with /path/to/my/project/xxx/react-native/Libraries/Animated/release/package.json
error: bundling failed: ambiguous resolution: module `/path/to/my/project/index.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:
This seems to be unexpected behavior. If the convention is for node modules to live under node_modules, why would Metro Bundler take it upon itself to look anywhere else?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Should I check in folder "node_modules" to Git when ...
I am the Node language owner at Heroku and the answer is simple: No. Do not check node_modules in to Heroku apps. β...
Read more >folders
Cycles, Conflicts, and Folder Parsimony. Cycles are handled using the property of node's module system that it walks up the directories looking for...
Read more >What Happened When I Peeked Into My Node_Modules ...
I opened up babel-core in vim, then turned off my computer because Ctrl-C wasn't exiting, then opened babel-core in Sublime Text 2. module....
Read more >API - esbuild
In node, you can load a module using node --experimental-modules file.mjs . Note that node requires the .mjs extension unless you have configured...
Read more >Dependency resolution
Parcel includes shims for many builtin Node.js modules, e.g. path and url . When a dependency specifier references one of these module names,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I use React-Native in combination with Electron to build iOS, Android, Desktop and Webversions of my Application. Electron generates a folder node_modules under ressource in its output. This folder is required to run the Desktop Application. Once the Desktop Version is compiled, node fails to build the iOS and Android, aswell as the Web Application since it will find two node_modules folders, containing duplicate modules.
This results in following errors:
The question is: How do I tell metro bundler to ignore a certain node_modules folder or specify which one it should use?
Rel: https://github.com/demokratie-live/democracy-client/tree/desktop Rel: https://github.com/nodejs/help/issues/1011
GrΓΌΓe Ulf
β€οΈ
I was able to fix this in my case by adding a rn-cli.config.js file to the root of my monorepo with the following content:
const metroBundler = require(βmetro-bundlerβ);
module.exports = { getBlacklistRE: function() { return metroBundler.createBlacklist([/NAME_OF_FOLDER_TO_EXCLUDE/.*/]); } };
When I switch from project to project I can just update the excluded folder and I am good to go. Two different versions of React-Native in the same monorepo.