Npm install is breaking my apps

Ever since upgrading to Node 8.0.0 and npm 5.0.1, I’m having a lot of projects getting the Expo XDE to compile my apps. I’m running on Mac OSX 10.12.5. I get errors like:

Error: React native is not installed. Please run npm install in your project directory.

Problem checking node_modules dependencies: Unexpected end of JSON input

Even though I just ran npm install many times. I also ran npm cache clean --force, I reinstalled both node and npm. Still it doesn’t work.

Does anybody have any ideas???

hello! npm5 is buggy and probably should not have been released in its current state. please use npm4 or yarn :slight_smile:

1 Like

Hey @notbrent. How would I use yarn instead?

1 Like

here’s a cheatsheet for npm → yarn: Migrating from npm | Yarn

1 Like

Thank you, using yarn and yarn install did the trick!

Hi I installed via yarn install but I still get this error in XDE:
"Problem checking node_modules dependencies: Unexpected end of JSON input". Altho everything seems to still work and I don’t have the “React native is not installed” error.

@notbrent do you happen to know why it behaves this way?

mmm probably still some npm5 bug because we do npm ls to examine your node_modules to see what’s missing. you should probably install npm 4 instead

1 Like

Thanks @notbrent since it’s not stopping me from building the app for now I will wait and see if it goes away after next few node updates.

In the meantime, is there anything I can do to find out a bit more which package is causing the Unexpected end of JSON input error?

i have no idea, you’d be better off just downgrading npm than trying to work around a bug :stuck_out_tongue:

1 Like

Np thanks @notbrent (posts must be at least 20 characters, yeah sure…)

1 Like

Hi, I run npm 5.0.3 to install react-apollo, then I get a package-lock.json, is this wrong? Do I need to do something to fix it?

After see your answer, I have downgraded npm to 4.6.1, can I go ahead to install reac-navigation or other packages now? Yesterday I use npm 5.0.3 to install react-navigation and also received the error message: React native is not installed.

basically you should not use npm5 on any projects right now. you can remove it and delete node_modules and package-lock and continue development as usual

1 Like

OK, Thanks a lot! I have downgraded the npm like you said, everything is ok now!

1 Like

great! :slight_smile:

1 Like

I’m having this same issue once again.

I tried using yarn, I tried using npm 4.6.1, i try deleting and reinstalling expo, i tried going back to a version that 100% worked, i tried restarting my computer, i tried deleting my node_modules folder / package-lock.json / yarn.lock files, I tried all those things expo tells you to do like “run watchman watch-del-all” and the other ones,I tried doing all of these things in different orders. But I still get errors like these:

unable to resolve module: node_modules/react-native/Libraries/Performance/Systrace.js module does not exist in the module map or in these directories ....

It always seems to have issue with loading the node_modules.

This is super frustrating. I sit down to code, and I end up troubleshooting expo for hours (when I haven’t made any change). What exactly am I doing to cause this to happen? What is the correct process for debugging this? I follow all of the recommendations in the error messages, but nothing works.

How to deal with situations when some npm packages won’t install with 4.* version of npm (4.6.1, to be precise). For example: firebase.

Is there work around for this?

Firebase installs fine with latest 5.* npm version.
My stackoverflow question.

This is the error I always get. Nothing seems to fix it. If anyone knows how to fix this, I would be so grateful.

I had the same issue but with a different error. None of the mentioned recommendations worked for me as well. Then I tried to create a new project using console, not XDE:

create-react-native-app your-app-name
cd your-app-name/
npm start
npm run ios / npm run android

Fortunately, that worked for me. Hope that may help you too.