React native keeps requesting react-native-cli to be installed globally - node.js

Here are the steps I did to set up my project:
$ git clone ssh:<project>
$ cd <project>
$ nvm install 5.0
$ nvm use 5.0
I then check my node version and it appears to be correct: v5.0.0.
$ npm install
$ npm install -g react-native-cli
This all seems to go according to plan, and locally, it gives me a tree with all the correct dependencies.
When I do npm list --depth=0 -g, I get expected results.
├── npm#3.3.6
└── react-native-cli#1.0.0
So I try to run the npm start script, which is react-native start. However, whenever I try to run it, I get the following basic error:
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cli
I've tried just about everything I can think of, down to uninstalling node and nvm completely and starting from scratch.
What is the solution to this problem?

This upcoming error message is not very helpful. Besides your npm installation issue I found also an npm start doesn't work after upgrade to 0.15.0 bugfixing issue with the same error message.
First of all you should check the symbolic link shown after npm install:
$ npm install -g react-native-cli
/usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js
Check if the linked file exists:
ls /usr/local/lib/node_modules/react-native-cli/index.js
If not, check your npm path settings with
npm config list
or directly in ~/.npmrc
In my case I had a wrong prefix in ~/.npmrc, which I've deleted completely. As the npm ERR! message shows after another npm install -g react-native-cli, it came up with:
npm ERR! Refusing to delete /usr/local/bin/react-native: ../lib/node_modules/react-native/local-cli/wrong-react-native.js symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/bin/react-native
npm ERR! Move it away, and try again.
Look at the indicated 'wrong-react-native.js' filename at the end.
Delete that link, do a npm update and try npm install -g react-native-cli again.
Worked on MacOS X. npm installed with homebrew

Related

Npm always showing me npm ERR! when I try to install anything

Please I need your help whenever I try to install anything with npm I always get errors please help me.
Update
From what read from the docs you should install the #ionic/cli
$ npm install -g #ionic/cli
From the docs:
If there was a previous installation of the Ionic CLI, it will need to be uninstalled due to a change in package name.
$ npm uninstall -g ionic
$ npm install -g #ionic/cli
You may want to add debug info while installing e.g.:
$ npm install -dd -g #ionic/cli
From your screenshot not sure if there is an error with your GIT config, or permissions to install the ionic cli globally on your machine...
Outdated
There should not be a space between ionic and #4, you should run e.g.:
npm install -g ionic#4
You can try with command like this npm install -g ionic#{{version}}.
In the place of version you should put your prefered version.

how to update npm version in Ubuntu (with permission)

I'm using Ubuntu 16.04 LTS and install node + npm. I know that I can't run npm command without sudo. Then I change my directory and give it permission that provide from this link https://docs.npmjs.com/getting-started/fixing-npm-permissions .
But when I try to run npm install npm#latest -g, npm will update the user-permission-given npm version, so when I run npm -v it will actually show me the version of root-permission npm not the user-permission-given npm. I want to know if I can change my npm global path to the permission given npm or there's another solution?
nb: I try to run root-permission npm (I delete user-permission npm folder from PATH) to install latest npm version, but it install latest npm with root-permission to my user-permission npm directory, which is give me more problem.

Local grunt installation gives error

npm install -g grunt-cli //done successfully
npm install grunt --save --only=dev
gives following error
(node:11000) fs: re-evaluating native module sources is not supported. If
you are using the graceful
-fs module, please update it to a more recent version.
npm WARN prefer global coffee-script#1.10.0 should be installed with -g
project#1.0.0 C:\Users\Live\Desktop\node grunt\final
`-- (empty)
npm WARN project#1.0.0 No repository field.
npm ERR! code 1
Tried uninstalling grunt-cli, cleaning npm cache, then re-installing, but still the problem persists.
Ok short recap:
When in doubt remove your node_modules and install all packages again using npm install
If that didn't work, try updating your npm by executing npm update -g npm and redo step 1.
If that didn't solve your problem, try upgrading to another NodeJS version using nvm or n.

create-react-app, installation error ("command not found")

I have installed create-react-app exactly as instructed on the facebook instruction page (https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html):
First, install the global package:
npm install -g create-react-app
I did this. It appeared to work fine - the file was installed to
users/*name*/.node_modules_global/lib/node_modules/create-react-app
I'm not really sure why global install takes it to this path, but there you have it.
Next instruction:
Now you can use it to create a new app:
create-react-app hello-world
Couldn't be simpler, right? But Terminal spits out this at me:
-bash: create-react-app: command not found
It's probably something very simple I'm missing but I don't really know where to look. If anyone can help I'd really appreciate it!
Note: I'm using Node v6.3.1, and npm v3.10.3
You are able to apply the following solution:
$ npm config set prefix /usr/local
$ sudo npm install -g create-react-app
$ create-react-app my-app
The environment variables are not set properly.
When you run the create-react-app it shows you a path along with the error. Copy that path and add it in the environment variable.
Alternatively you can use the command:
npx create-react-app <app_name>.
This will do the work for you.
Your Node setup looks incorrect. It's not an issue with Create React App—it seems like you can't run any global Node commands.
It looks like ~/.node_modules_global/bin is not in your PATH environment variable so it can't execute global commands. That's just how Bash works—it can't guess where the command lies, you need to tell it. I would assume Node installation should do this by default but it depends on how you installed Node.
So make sure that directory is in your PATH and try again. If you use Bash, add this to your .profile and then restart the Terminal:
export PATH=$HOME/.node_modules_global/bin:$PATH
Try this. It worked or me. I found this in the React documentation. "Npx" is not a typo. It's a package runner tool that comes with npm 5.2+.
npx create-react-app my-app
In 2020 Dec 17
Install Nodejs & npm
sudo apt update
sudo apt install nodejs
sudo apt install npm
if you install maybe show you this like errors for Reactjs setup.this helpful for you
npm install -g create-react-app
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-12-17T14_16_02_442Z-debug.log
then When you type after this
create-react-app test-react-app
Show you in terminal
zsh: command not found: create-react-app
you fix this error by using this command
sudo npm install -g create-react-app
create-react-app test-react-app
I hope work fine for you also.
Use npx instead of npm.
Check this out-> https://reactjs.org/docs/create-a-new-react-app.html#create-react-app
Answers given above are right but I want to share some things that I also faced and these are basics.
To setup react project
If you want to create a node environment
$ sudo apt-get update
$ sudo apt-get install nodejs
(Sometimes we can also run without sudo; but sudo means install in system level.)
$ sudo apt-get install nodeenv
$ nodeenv env
$ source /bin/activate
If you want to create new react app then
$ npm install create-react-app
If an error occurs create-react-app: command not found then install with -g, it happens because node is installed globally and it is not getting the node in local
$ npm install -g create-react-app
$ create-react-app app_name
$ cd app_name
app_name$ npm start
I hope you already installed Node package manager(npm).
now run npm install -g create-react-app, if everything fine then you can use create-ract-app command.
if you are getting any permission error just sudo npm install -g create-react-app.
I hope it will work.
Happy Hacking.
if you face following this problem:
create-react-app: command not found
solution:
sudo npx create-react-app react_spa
cd react_spa
sudo npm start
I hope its work.
If above answers are not working, then try this
update the npm version (npm install npm#latest -g)
clear the cache (npm cache clean --force)
create the react project (npx create-react-app myapp)
(while running the 3rd command, make sure that create-react-app is already installed in the pc)
This is how I get it fixed.
Step # 1:- Make sure, Node js and React js is installed globally. You can check Nodejs by
node --version . If not installed, install and run
export PATH=$HOME/.node_modules_global/bin:$PATH
Step # 2:- Clean your npm cache by following the command
npm cache clean --force
run
sudo npx create-react-app your-app-name
And that's it. you're done.
Please note, This solution worked for me for MAC OS
I tried all methods listed above and in other sites. They weren't working for me. But for some reason I decided to add the create-react-app directory into my system variables as a last ditch method and to my surprise this actually worked.
I faced a similar challenge but on running the command
npm i tar
I was able to resolve the issue.

NPM Install is not installing dependencies

I'm attempting to install the Ushahidi V3 Client. I've been following the install process up until when I need to build the project from the source repo using npm and gulp - both of which I've had zero experience with. Whenever I run sudo npm install in the project directory, the process runs without complaints. However, when I run npm ls to verify that dependencies have been downloaded, I get a bunch of dependencies listed out as being missing.
How do I get npm to resolve all of these dependencies?
System Details
OS Ubuntu 14.04 (Trusty)
Node JS v0.12.9
NPM v3.5.1
What I've tried
Removing node_modules folder and re-running sudo npm install as referenced in this SO answer for a similar question: npm Gulp dependencies missing, even after running npm install
Uninstalling and reinstalling node and npm
#Strainy, as your research :D
It was a combination of running as sudo and not having the build-essentials.
That's why you should not use sudo npm
Follow these steps:
try npm uninstall. and then try npm install.
Also If it still doesn't work.
Try:
npm install -g npm-install-missing
or
npm-install-missing
For further reading, click here.

Resources