Open aaroncraig10e opened 6 years ago
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:
Scanning folders for symlinks in D:\sources\demokratie-live\democracy-client\node_modules (66ms)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Running Metro Bundler on port 8081. β
β β
β Keep Metro Bundler running while developing on any JS projects. Feel β
β free to close this tab and run your own Metro Bundler instance if you β
β prefer. β
β β
β https://github.com/facebook/react-native β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Looking for JS files in
D:\sources\demokratie-live\democracy-client
Metro Bundler ready.
Loading dependency graph, done.
Bundling `index.js` [development, non-minified] 0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `D:\sources\demokratie-live\democracy-client\index.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:
* `D:\sources\demokratie-live\democracy-client\dist\win-unpacked\resources\app.asar.unpacked\node_modules\react-native\package.json`
* `D:\sources\demokratie-live\democracy-client\node_modules\react-native\package.json`
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
<3
Bump - this issue prevents us from deploying Desktop Versions of our Software </3
GrΓΌΓe Ulf
<3
+1
I am also having this isssue, albeit for different reasons. I am using a monorepo approach for my current project and if I want to have multiple projects with different versions of react-native I have to remove and the node_modules folder from one project so as to avoid getting this error.
Being able to specify which path to ignore would allow me to circumvent this issue and have two react-native projects within the same monorepo using different versions of react.
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.
My workround:
const metro = require("metro")
module.exports = {
getBlacklistRE: function() {
return metro.createBlacklist([/dist\/mac\/.*/, /dist\/win-unpacked\/.*/])
},
}
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?