-
Notifications
You must be signed in to change notification settings - Fork 24.2k
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
Invalid directory /Users/node_modules/Dimensions #3817
Comments
ResolutionRequest.js is redirecting the require()'s from the module... it looks through these search paths:
Then errors when the module could't be found. The problem of course is that Dimensions is in - '/Users/username/Dropbox/Dev/project_name/node_modules/react-native/Libraries/Utilities' I assume that we should be checking the cache of react-native modules before checking the directories? |
...I can change the library to use import { Dimensions } from 'react-native' but as it used to work and I couldn't find any mention of this being a breaking change require('Dimensions') should be allowed to work. |
If I add custom potential paths to the searchQueue in ResolutionRequest.js I end up with a working app. This obviously won't be the best way to get to the top level of the react-native module and we would want to include paths recursively but as a quick demo it works: searchQueue.push( path.resolve(__dirname + '/../../../../../Libraries/Utilities/' + toModuleName)); |
The |
I do for my own code but unfortunately I can't say the same for various modules I use. It could be a useful compatibility mechanism. I also couldn't figure out how to import StyleSheetRegistry. This wasn't working: import { StyleSheetRegistry} from 'react-native' Admittedly I'm not all that used to the import style so maybe I'm missing something. |
I'm getting the same error upon update but with static images:
Agreed, I'm not sure why React Native is looking there - everything looks fine on the Xcode side and it worked before update. |
Ah, this was my fault - assets need to be included different in React Native 0.14.0+ |
In react-native 0.14.2, directly `require()`ing `Dimension` throws a packager error. It should be imported via the destructuring syntax instead. See: facebook/react-native#3817
I've run into this as well and backed out of 14.x because of it. I'm seeing other custom modules receiving the same type of error. almost/react-native-sqlite#33 (comment) @nicholasalanbrown, what did you do to resolve this? |
@jaygarcia well my specific issue was with include local image assets - the solution is above. I'm also seeing it with other packages that try and require NativeModules directly - I don't think there's a fix other than editing the package require statement itself. As far as I can tell, this is a breaking change that wasn't called out in the release docs. I'm not sure why it wasn't implemented as a warning rather than a complete failure point. It does really suck that those packages will be useless until their authors make the change. You could submit a PR to the author to expedite the process. |
@vjeux @nicklockwood @frantic can you guys weigh in on this? This seems to affect everyone who's extending React Native. |
@nicholasalanbrown Can you be more specific about the fix you made for the assets error. Not clear to me exactly what you did. |
@jaygarcia are any of the folders under node_modules symlinks? Packager has a hacky script that tries to guess the repo root, and it may cause problems with symlinks (cc @martinbigio) |
Just ran into the same error with Dimensions. Looks like there are other issues with packager but i thought i'd mention this. Changing to destructuring syntax off of the react native object instead of require or import of the Dimensions package directly fixed the issue for me. |
Closing in favor of #4968 . Let's track it there. |
Node js have group of possible folders that can contain modules. When you install one module sometimes module can be dependent to other modules. You have to install this dependancies manual. For example if the error is like /Users/node_modules/module you have to install "npm install -S module". It is showing error as missing path in /Users/node_modules because this is the last element of array full with possible paths that can contain modules (for MAC). Full list of paths by OS : https://www.npmjs.com/package/npm-paths |
Hi,
I've just started using 0.14.0-rc and migrated from an early version. I opted to stop using CocoaPods and go it "alone" instead.
The directory structure is setup as per the result of "react-native init":
Everything on the Obj-C side builds and runs in the iOS simulator
React native is giving the following error however:
Error while loading: Unable to resolve module Dimensions from any_npm_module: Invalid directory /Users/node_modules/Dimensions
Clearly that's an odd place to be looking for the module...
I'm digging into the code but has anyone any pointers?
Thanks
Luke
The text was updated successfully, but these errors were encountered: