-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Packager] doesn't resolve modules that are symlinks #637
Comments
is it a bug or is it by design? |
Just ran into this trying to develop a npm library locally using |
I thought we supported this use case. Thanks |
Perhaps related, relative requiring a module above the iOS/React Native directory fails the same way:
Error: Requiring unknown module "../common/auth". If you are sure the module is there, try restarting the packager. I tried symlinking that higher-level directory within the React Native project to fix, but it failed as well, leading me to this issue. |
I finally had some time to make an example to prove it's not working. Check out this repo which references the example app component through a symlink, which doesn't get resolved. https://github.com/JaapRood/react-native-packager-symlink-bug Now, if only I had any idea on why. |
I have an internal fix for this. Aiming to get it out next sync :) |
Awesome @amasad - looking forward to this, will make lib development easier |
Great @amasad, that would be immensely helpful! |
@amasad no pressure, but when to expect next sync? :) will it be in 0.6.0 release? |
still an issues as to 0.6.0 and 0.7.0-rc ... |
That's strange. I'll give @JaapRood's test project a spin see what the problem is. |
👍 Same problem here. Symlinks are very useful, especially when I don't want to make a node package just to share a component between two related React apps. |
it generally usefull for many global acessible parts of your application: constants, configs, reusable components replacing react-native base components (styled Text for example) |
@amasad - any updates here? |
👍 |
Figured out a little more about the cause -- the issue goes away when switching to the Node-based watcher instead of the Watchman-based one. The watchman homepage says, "Watchman does not follow symlinks. It knows they exist, but they show up the same as any other file in its reporting." so this could be the root case. Support for symlinks seemed to get pretty strong pushback in facebook/watchman#105 so perhaps the packager could use a combination of Watchman for most files and the Node watcher for symlinked packages. npm linked packages reside in the first The npm link workflow is really important for anyone developing a React Native module so I do think this is a priority for the external RN community. |
I'm not sure if this is related or not. I have a symlinked folder for some of my js files in the project root. These are some internal libraries that are part of another repo. I am importing them using require('./lib/file') where lib is a symlink to a folder. This is working in the packager in 0.7.1 and not working in 0.8.0-rc. I am using io.js. I figured I'd put this here in case some code is changing in 0.8.0-rc related to this bug... |
For 0.8.0-rc, the problem is To solve the problem, I must launch the packager with an additional argument I'm not sure what's the best solution for this issue? |
I use 0.8.0, after close all terminal, xcode, restart. then everything is OK. |
For those who have missed the release of 0.9.0-rc it's listed there as a known issue. |
Is there any good workaround here? |
I've found that this can be worked around by uninstalling watchman and therefore forcing react native to use the default node file watcher, however this does have speed drawbacks, and you can come up against issues with the number of files being accessed depending on the project. -------- Original message -------- Is there any good workaround here? Reply to this email directly or view it on GitHubhttps://github.com//issues/637#issuecomment-131214239. |
Sorry for the delay, was out for a while.
What happened is that we started using watchman for the filesystem crawling. My understanding is that watchman doesn't follow symlinks but should treat them like any other file. Which in theory should still work. I can try to debug this soon. Alternatively we can add an option to force not using watchman for filesystem crawling. |
Hi guys, any update on this ? My only way to develop a react native library is to git clone my repo inside my node_modules, isn't it ? |
Hey guys, Take it or leave it, but you are all welcome to use it. I've patched both the 0.42-stable branch and the 0.43-stable branch but haven't really tested 0.43 since it relies on an alpha version of react. To use 0.42-stable update package.json react-native dependency to: For 0.43-stable use: |
Not sure but probably node option I had similar problem with symlinked files/modules (but on regular node project) and this option resolves problems for me. |
We definitely need to find way how to run React Native Packager with |
Any update on this? I was surprised to see npm and just normal *nix symlinks dont work at all |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 |
Please avoid adding metoo +1 comments, as it distracts from the conversation. May I suggest using reactions instead? |
@hramos The main problem with reactions that they don't attract any attention, but I agree that seeing that many |
I hope it is annoying enough so they finally fix a 2 year old issue. |
probably not though |
This wasn't in the original post, but please note that this isn't some obscure feature request. Also, I tried it on macOS and linux and same issue occurs. |
The RN packager was built for Facebook's needs; which unfortunately (for us) didn't include symlinks. But... packager will be getting some love shortly. Hoping to see some news this week. In the meantime:
|
+1 |
Can you move this to https://github.com/facebook/metro-bundler now that the packager has been moved out of React Native? |
Hey guys I found a pretty good workaround: Basically because react-native doesn't respect symbolic links, the files need to be indistinguishable from the real files with hard links. The problem with hard links is that they don't work for directories. |
Update: this seems to only partially work. It does reflect the changes in my editor, for example, but react native won't notice the change until I 'save' the updated file (even though saving isn't changing the file contents). |
Closing, please reopen in the metro-bundler repo. |
See facebook/metro#1. |
+1 having the issue with npm link. -- app1 where I will writ components in the shared folder. I tried to use the idea from here: https://stackoverflow.com/questions/8088795/installing-a-local-module-using-npm |
Locking conversation, now that this has been moved to facebook/metro#1. |
As described in the browserify handbook you can use symlinks in the
node_modules
folder to reference modules. This is mainly useful for preventing../../../../
requires.With a symlink setup from the project root setup like:
ln -s src/app node_modules/app
in any file in the project you can:
However, the packager can't resolve them:
Requiring unkonwn module "app"
.Edit:
Check out this repo to easily reproduce the error above:
https://github.com/JaapRood/react-native-packager-symlink-bug
The text was updated successfully, but these errors were encountered: