Skip to content
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

npm_module config gets required from /Users/node_modules instead of ./node_modules #3975

Closed
peveloper opened this issue Nov 7, 2015 · 19 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@peveloper
Copy link

When requiring config :

var config = require('config');

which is included in package.json as:

{
  "name": "sample",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start"
  },
  "dependencies": {
    "react-native": "^0.14.0",
    "config": "^1.16.0"
  }
}

apparently react-native is searching in the wrong folder:

Unable to resolve module config from /Users/user/Documents/dev/AwesomeProject/index.ios.js: Invalid directory /Users/node_modules/config
@jedrekk
Copy link

jedrekk commented Nov 15, 2015

I'm getting this issue with any NPM module I try to use.

@jmreidy
Copy link

jmreidy commented Nov 17, 2015

+1 - all requires of node_modules appear broken.

Update: I attempted to recreate this issue with a vanilla project and was unable to. So there's something about an active project config that's breaking the packager. I'll continue investigating on my end.

@nc
Copy link

nc commented Nov 17, 2015

👍 seeing this too Invalid directory /Users/node_modules/react-native"

@jmreidy
Copy link

jmreidy commented Nov 17, 2015

Interestingly, I'm only seeing this behavior with firebase right now. I can require redux and associated modules without a problem.

@jmreidy
Copy link

jmreidy commented Nov 17, 2015

I have a fix. Sadly it makes no sense. I uinstalled firebase, reinstalled, tried installing a different version, restarted xcode - nothing worked. But the following steps DID work:

  • mv node_modules/firebase node_modules/fbase
  • change require to require('fbase');
  • build and test in simulator - looks correct
  • move fbase back to firebase
  • change require back to 'firebase'

Then everything worked normally.

@peveloper
Copy link
Author

Wow that's annoying. Later I will try your solution with other npm packages. Btw great job @jmreidy, really appreciated.

@skevy
Copy link
Contributor

skevy commented Dec 11, 2015

Hey everyone, can you all try:

  1. upgrading to latest RN
  2. watchman watch-del-all
  3. rm -rf $TMPDIR/react-native-packager-*
  4. restart the packager

And let me know if that fixes the issue?

@jmreidy
Copy link

jmreidy commented Dec 15, 2015

@skevy I just created a new test repo, recreated the bug, and then ran your commands. That fixed the issue in the test repo!

@ghamaide
Copy link

@skevy doesn't work for me... still the same error

@DaveAdams88
Copy link
Contributor

Hi guys,

I am also getting this error when using jsdom-jscore (or jsdom/jsdom-little)

uncaught error Error: UnableToResolveError: Unable to resolve module querystring from /Users/•••/•••/•••/node_modules/react-native-svg/node_modules/jsdom-jscore/lib/builtins/url/url.js: Invalid directory /Users/node_modules/querystring at ResolutionRequest.js:351:15

I have tried the steps from both comments by @skevy and @jmreidy but no luck.

I have also completely removed node, nvm and npm from my mac and then reinstalled following the steps on the react-native setup guide (using latest node and npm@2). Then reinstalled node_modules in project (I had removed them before setting up node), but still the same error

@julipur
Copy link

julipur commented Dec 21, 2015

I'm having the same problem with numerous packages. I start working on a new project and it works. I bring in a new package and it randomly stops working and I start getting the same error looking in users/node_modules. Does not matter which package. I start a new project and add the package it is complaining about and it works.

I am new to node, but have been playing with react-native for last couple of weeks and always run into this issue.

@matias-casal
Copy link

@julipur do you have the solution?

@julipur
Copy link

julipur commented Dec 22, 2015

@Casy Not really.

If I stop everything and git clone my project into a new folder and then npm install, it works. That's the workaround that I've been doing.

This does sound like some sort of caching issue. If I understand correctly the solution by @skevy above in the thread would solve the caching issue, but that has not worked for me.

@yonahforst
Copy link

i've got this problem too. just started after updating react-native:0.17.0-rc to 0.17.0, although that might not be related (Downgrading back to 0.17.0-rc doesn't fix it)

@yonahforst
Copy link

also, on my machine, the tmp files weren't named react-native-packager-*

try running rm -rf $TMPDIR/react* instead

@satya164
Copy link
Contributor

Closing in favor of #4968 . Let's track it there.

@lipengx
Copy link

lipengx commented Aug 1, 2016

2016-08-01 12 22 22 It is not work as the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.
    What can 1 do

@ddalev
Copy link

ddalev commented Aug 8, 2016

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

@sevli
Copy link

sevli commented Jul 10, 2017

who can help me to resolve this question !???

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests