How to see changes based on node_modules reaction

When I run react-native start or npm start , the packer starts up and asks Looking for JS files in /Users/map/repos/myrepo/

I have a hot reboot enabled. When I modify the file located in /Users/map/repos/myrepo/node_modules/react-native/ it seems to detect the change, however, if I edit the file in a third-party repository, for example /Users/map/repos/myrepo/node_modules/react-native-menu/ , it looks like the watchman is not detecting the change.

I just upgraded React Native in my project to 0.39, and I think this was not the default before. I set some entries in react-packager/src/node-haste/index.js and it seems that react-native-menu files are included in hasteFSFiles , however change does not hasteFSFiles event.

I tried to remove node_modules and reinstall it, clear the state of Watchman and stuff without luck.

+6
source share
2 answers

Good. It looks like they remade the React Native packager in version 0.39, although this error is still present in v0.40. Until there is an official fix, if you want to detect library changes in node_modules , you need to edit node_modules/react-native/packager/defaults.js and add the project name to providesNodeModules , for example:

exports.providesModuleNodeModules = [ 'react-native', 'react-native-windows', 'react-native-menu', ];

The question of where this was reported can be found here: https://github.com/facebook/react-native/issues/11301

+6
source

Another solution is to start responding to your own package with additional arguments

npm run start -- --providesModuleNodeModules react-native,{any_node_module}

Works with RN v0.42.0 for me

+3
source

Source: https://habr.com/ru/post/1013921/


All Articles