Create-react-app returns "Cannot find module 'rxjs'" - node.js

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?

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

Related

Create vue Permission denied

I'm trying to install vue app using this command "npm init vue#latest",
But the following error occurred with me, any help :(
Note : I tried many solutions like : chmod -R 755 .npm and sudo chown -R mostafa .npm but nothing changes
maybe you could try using the vue-cli like this:
npm install -g #vue/cli && vue create hello-world
If this wouldn't work then I'd suggest to reinstall node/npm
You should probably also make a clean installation of these tools so that you don't need to run such things as administrator
In order to install vue on your machine you must first have installed nodejs ( package manager node package manager ) to which the acronym npm refers, I leave you the linux commands under :
install :
sudo apt install nodejs
shows the installed version of nodejs :
node -v
After installing nodejs try relaunching the command to install vue
if you have already installed them try with this :
add write permissions to the study folder , and not to the mostafa folder , linux only assigns permissions to the folder in the chmod command and not subfolders, try these commands :
cd home/mostafa/Dowloads
sudo chmod ugo+w study
Are you not being blocked by SELinux directives?
Try running the same command using your least privileged user (normal user).
And please avoid using the root user for everyday tasks.
You need to have installed Nodejs, vue and create-vue.
sudo apt install nodejs
npm install vue#latest
npm install create-vue#latest
Now you can run the command to start the new project with Vue.
npm init vue#latest

How to delete the localy installed version of npx command?

When I execute a command with npx, npx propose me to install a version locally.
Example
npx matcha-stock -s=MSFT
If the version is updated on npm.org, npx gives me only the version installed locally and doesn't check if an updated version exists.
If I execute
npx matcha-stock#latest -s=MSFT
I get the latest version of the tool.
But, if I execute again
npx matcha-stock -s=MSFT
I got the previous installation.
Question: How to uninstall, clear the cache of the locally installed version of the command ?
#npx #NPM
The dependencies of each of these commands are stored in a cache at .npm/_npx/*/node_modules, when I tried blowing all those away it worked.
Finding which one to delete
ls ~/.npm/_npx/*/node_modules | grep matcha-stock
Just deleting them all
rm -r ~/.npm/_npx/

Cant fix npm permissions mac mojave

I have spent the last few hours trying every tutorial out there on how to fix npm permissions on a mac.
NOTHING has worked thus far.
Steps I have taken
I have uninstalled node multiple times, tried running brew install node --without-npm then installing npm seperately.
I have tried to create my own npm-package file in my root directory and change the npm source and still that doesnt work.
I have tried what is detailed here https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md
I have tried what is shown in this video https://www.youtube.com/watch?v=bxvybxYFq2o&t=154s
I have also tried a few other techniques all similar to above but nothing has worked.
Im on a 2015 macbook running a fresh install 0SX Mojave.
Any time I try to install a package it errors, and even if I use sudo, npm cant find the commands I'm entering for example if I
sudo npm install #angular/cli then try and use ng I get the command not found: ng
Any help would be appreciated. This question will be updated with methods used as they are suggested. Let me know If you need any more information.
I understand your frustration :(
These steps worked for me (from https://github.com/creationix/nvm/blob/master/README.md):
check if you have ~/.bash_profile file (home directory). I didn't. So I had to create it myself with:
touch ~/.bash_profile
Get NVM by running:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
them run
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
verify nvm installation by running (you might need to restart terminal window before)
nvm --version
Install node via nvm - run:
nvm install node
(if you get version warning/error just follow the instructions(I had to run npm config delete prefix and then again nvm install node))
Install CLI:
npm install -g #angular/cli
verify installation:
ng -v
Hope it helps!

Jenkins is not installing some node dependencies

I'm running a nodejs application's build on jenkins. I run node as shell script step, because I have some limitations in terms of the plugins I can install in this jenkins instance.
This is what the npm install step looks like:
#!/bin/bash +x
source ~/.bashrc
cd $WORKSPACE/ && \
nvm use 7.8.0 && node --version && npm install
The problem I have is, when npm install finishes, it doesn't install everything. If I ssh into the box where jenkins is installed and run npm install inside that project's workspace, with the same user jenkins uses, it works ok. Any ideas?
EDIT
I just realized the dependencies that it's not installing are devDependencies
The problem was I had the node env set to production, and of course, it wouldn't get the devDependencies...

Nodemon installed but can't be found

I've tried uninstalling and and reinstalling nodemon several times both locally and globally with:
npm install -g nodemon
(tried it both with and without sudo)
and it seems to install no problem, and gives me:
/usr/local/bin/bin/nodemon -> /usr/local/bin/lib/node_modules/nodemon/bin/nodemon.js
/usr/local/bin/lib
└── nodemon#1.11.0
but whenever I run
nodemon server.js
in my app, I get;
-bash: nodemon: command not found
Like I mentioned, I've tried the same process but installing locally to my app dependancies, but it doesn't seem to make a difference. What's going on here? I followed the same process on a different machine, and it worked no problem.
Googling around, I came across some posts that mentioned changing/adding the PATH? But it's not clear to me if that's or the problem or what that means.
Also, other globally installed npm modules run just fine
nodemon is not being found by bash.
Edit your ~/.bash_profile file and add:
PATH=$PATH:/usr/local/bin/bin/
Start a new shell to see it work, or run source ~/.bash_profile to have it apply to the current session.
Instead of using sudo switched as root and then just run:
$ npm install -g nodemon
sudo su -
export PATH=$PATH:/home/USER/npm
npm install -g --force nodemon
# THESE LINES + START FROM A NEW TERMINAL...
# IN MY CASE
npm install -g --force node-inspector
# TOO

Resources