0

I've just installed NodeJS and NPM in a new machine. I added rxjs package in all my existing projects in order to make then start properly. However, when I run create-react-app - using npm globally or npx - I receive "Error: Cannot find module 'rxjs' ". Seems like rxjs is a new dependency of something (considering it's affecting old projects too).

I have already changed Node version to 8, 10 and 12. Reinstalled NPM, changed CRA version to 2.x.x and the trouble persists.

How can I use CRA without this problem?

1 Answers1

0

As mentioned by the Original Poster in the comments, the fix could be to clear your cache.

npm cache clean --force

If this still doesn't work, you can follow the steps below to install and try with Yarn:

If neither npx create-react-app my-app and npm init react-app my-app are working for you, try Yarn to see how it goes.

I have used CRA is multiple projects on Windows, Ubuntu, Mint and macOS and have never explicitly installed rxjs, nor have I been asked for it. This leads me to think that this problem is almost certainly caused by sth local to you rather than sth wrong with CRA. I assume that you have searched through their issues on Github.

Try it with Yarn Open a new terminal (linux and macOS) or command line (Windows) session cd'd to your documents folder or suitable alternative. Then run:

macOS

brew install yarn

yarn create react-app my-app

Windows (with Chocolatey)

choco install yarn

yarn create react-app my-app

Ubuntu

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update && sudo apt-get install yarn

yarn create react-app my-app

AlexJeffcott
  • 116
  • 2
  • 5
  • Same with yarn. Yep, I have searched and there is no issue about it on GitHub. – Yuri Delgado May 05 '19 at 18:18
  • What OS are you using? You mentioned that it was a new computer, so I assume that it was a clean install, correct? What do you get when you run: `node --version && npm --version && create-react-app --version` – AlexJeffcott May 06 '19 at 07:55
  • I'm using Fedora 29. I made a clean install of it on SSD. I was using Fedora 28 on HDD with no problem. NodeJS: v10.15.3 NPM: 6.4.1 CRA: 3.0.0 – Yuri Delgado May 06 '19 at 20:56
  • If I have understood correctly, I think that the best course of action is would be to open a ticket with CRA with a minimal example for replication. Sorry I couldn't be more helpful. – AlexJeffcott May 08 '19 at 07:28
  • Np. Thank you anyway. It doesn't seem to be a CRA problem since `rxjs` was required to other projects created months ago. – Yuri Delgado May 08 '19 at 15:38
  • `npm cache clean --force` and reinstalling CRA, version 3.0.1 now, solved my problem. I believe the first step was the real solution. – Yuri Delgado May 11 '19 at 14:48