about 'zsh react-native command not found' AFTER SETTING PATH - macos

Some time ago, I had the command not found error when running expo, so I set path at ~/.bash_profile and so, after running source ~/.bash_profile, now I can call expo without problems.
Today, I tried running react-native link and the following error appeared:
zsh: react-native command not found
What else could I be doing wrong?

Maybe you don't have react native cli installed globally, which is good as it's not needed.
Check in the project directory if react-native is installed
so ./node_modules/react-native/ should exist and has something inside.
If so, you don't need to run react-native directly; try running through npx react-native or npm script.
If not, make sure you have react-native in package.json dependencies section, and run npm install to pull the react-native library folder.

Related

"NPM install" command line cannot run in LARAVEL project directory

I want to work with webpack and Laravel
I'm trying to install Mix in my Laravel project.
So i have installed node and npm succesfully.
When i run node -v and npm -v in vscode it show me the version number so i think the install is ok.
But when i go in the Laravel project directory and try to run "npm -v" or "npm install" i have a message like "npm: The term 'npm' is not recognized as the name of cmdlet, function, file
script or executable program"...
Did i do something wrong?
My bad...
I had another session of Vscode runnign on the other screen and i didnt see it.
I closed all vscode session and reboot and it work
Thank you very much!

"exp: command not found" How do I add expo cli to path?

I installed the expo cli with
npm i -g exp
then I run
exp
and I get
-bash: exp: command not found
I'm guessing I didn't add exp to path. So how do I do this properly? Nothing I've tried so far works.
This suggested 3 steps solution worked for me:
First check if ~/.npm-global/bin is in your path: echo $PATH. If it isn’t there, you will need to add it to the path.
Open up ~/.bash_profile then add the following line to the bottom: export PATH=$PATH:~/.npm-global/bin
Finally, back in the shell, type: source ~/.bash_profile
Hopefully that will have fixed your problem.
1. Find the path where expo is globally installed by npm:
npm bin -g
2. Add path from Step 1 to paths file:
sudo vi /etc/paths
3. Restart the Terminal
You should try npx expo init <your_app_name> to test.
It worked for me.
I also had a hard time getting expo command to work on Mac. Here are the steps I took to get it working.
npm root -g shows the directory the global modules are installed in:
/usr/local/Cellar/node/11.7.0/lib/node_modules
That directory might be different for you. After confirming expo is in there, edit ~/.bash_profile and add the line:
export PATH=$PATH:/usr/local/Cellar/node/11.7.0/bin
Save & exit, then run source ~/.bash_profile
Now the expo command should function as intended.
try sudo npm install --global expo-cli
this worked for me.
➜ MobileDev git:(campaigns-responsive) ✗ expo whoami
› Not logged in, run expo login to authenticate
➜ MobileDev git:(campaigns-responsive) ✗ expo init App
✔ Choose a template: › blank a minimal app as clean as an empty canvas
✔ Downloaded and extracted project files.
📦 Using npm to install packages.
✔ Installed JavaScript dependencies.
✅ Your project is ready!
To run your project, navigate to the directory and run one of the following npm commands.
- cd App
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios
- npm run web
exp was replaced with expo
To install Expo CLI, just run npm install -g expo-cli (or yarn global add expo-cli, whichever you prefer).
Following on this issue, I found I had multiple global folders so I started using a .npm-global folder as shown here: https://docs.npmjs.com/getting-started/fixing-npm-permissions
And now it's all clean and in control.
I had a similar issue.
-bash: expo: command not found
It turns out the command to install expo
npm install -g expo-cli was referencing an older version of node on my machine; when checked using npm root -g.
So I had to uninstall nvm/node, deleted any remnant folders & files of .nvm and shortcuts for nvm in /usr/local. Then reinstalled node and ran npm install -g expo-cli again.
That fixed my issue.
sudo npm install --unsafe-perm -g expo-cli
If you're using git bash on windows, add npm path to your system path variables. Generally located on this location:
C:\Users\<Username>\AppData\Roaming\npm
Then open the bash and command npm start. Hope this will help.
I solved it by putting this in my PATH environment variable / user variable:
C:\Users\{userName}\node_modules\.bin
yarn expo start
Worked for me.
npx create-expo-app project-name

NPM Packages (with CLI) installed globally return command not found

I've had this happen twice to me before. The first time I assumed it was an error with NPM, so I uninstalled Node & NPM and didn't use the package that was giving me an error.
I did a fresh install & began working on another project. I'd installed the package (and the version of it with cli). The command line command worked during the terminal session during which i'd installed it both globally and in my project. However in other terminal tabs and in new terminal sessions the command returns command not found.
when I run npm root i receive:
/Users/MYUSERNAME/node_modules
and when I run npm root -g, i receive:
/Users/MYUSERNAME/.npm-global/lib/node_modules
For what it's worth the two packages I've tried this with are mjml (and mjml-cli) and gulp (and gulp-cli). I've uninstalled both and reinstalled again from my root directory using the -g flag and that doesn't seem to have changed anything.
I appear to have missed this somewhere in the googling I did before asking this question.
Apparently I had been accidentally installing global packages in my local folder (/Users/YOURUSERNAME/node_modules).
Running npm config set prefix /usr/local fixed the issue.

'ionic' is not recognized as an internal or external command

I have successfully installed Ionic. In fact, I have ran it many times already and it worked perfectly fine (on my browser using "ionic serve" command).. But when I have not done "Ionic stuffs" for a few days, and tried doing it this morning, the command is now unrecognized. What is wrong with this?
Running Windows 7 and ran into this issue myself. I ensured that I was running my command line as Administrator, cleaned the cache as suggested but continued to get the error that 'ionic' is not recognized...
After trying several other suggestions, I finally browsed to my nodejs location: C:\Program Files\nodejs
I ran the nodevars.bat to open the nodejs command prompt, ran the ionic command and everything worked as expected. I'm not sure what the issue is but running command from that .bat file appears to fix it.
I added this the path and all worked well.
%APPDATA%\npm;
I already solved it. :) For some unknown reason my ionic installation went MIA. And I didn't solve that directly, it had errors that says "Run as Administrator", etc when in fact I'm running Admin... The trick was to clean the cache before reinstalling Ionic using the npm cache clean command.
It had errors that says:
Run as Administrator
etc, when in fact I'm running as Admin... The trick was to clean the cache before reinstalling Ionic using the command:
npm cache clean
It worked for me. Just run npm command for cache clean and reinstall the ionic as:
npm install -g ionic
and it works perfectly fine.
After a couples days of this exact issue, I found my solution. Remove all of corodva with npm uninstall cordova and ionic with npm uninstall ionic. Then clear the cache with npm cache clear. View this for full removal https://stackoverflow.com/a/29429357/5144902
I then found that there was a couple folders still in my C:\Users\USERNAME\AppData\Roaming\npm. I could not remove this, as the file extension was too long. I opened cmd, and removed it with the DEL command. I then found that a node_modules folder was under my user folder. I removed that.
Then Global install with npm install -g ionic cordova. Works perfectly.
None of the solutions worked as permanent fix for me and it was pretty disgusting to use a fix every time I intended to use ionic. So, while browsing for a solution, I read some solutions that eventually led to this:
Go to your system settings->Advanced system settings->environment path. In my case, while the 'npm' was indeed added to the system path, it was separated by a single comma inspite of a colon (;). So, I replaced it with a colon and bingo! Please do restart your CMs before trying to test it. Hope it helps!
If you are on Windows, use Git Bash shell and have issues calling cordova and ionic,
maybe you'll have to add a path value to
c:\users[your username].bash_profile
this helped comparing windows path (cmd - echo %path%) with git bash shell path:
Git Bash doesn't see my PATH
for me, global paths were there, but user paths not. I had to add:
PATH=$PATH:/c/Program Files (x86)/Microsoft VS Code/bin:/C/Users/[my username]/AppData/Roaming/npm
answer here
İf "ionic" is installed;
1-Download and upgrade nodejs to latest version.
download nodejs
2- run command:
npm uninstall -g ionic
3-Clear these files:
C:\Users\user\AppData\Roaming\npm
C:\Users\user\AppData\Roaming\npm-cache
3-run command:
npm install -g #ionic/cli
İt is done:)
Go to nodejs installed directory ( in my case it's C:\Program Files\nodejs), then run the bat script "nodevars.bat" with administator permission. That solves my problem.
In the Windows environment, when we install packages with -g option they are not available sometimes while running the package through the command prompt. Steps below that worked for me —
Create a .npmrc file at C:\Users{username}\
Write below line in the .npmrc file. Write path as per the location of nodejs installed in your machine. Add double back slash wherever you have a back slash in the path.
prefix="D:\\programs\\nodejs"
Run the command to install the package again
npm install -g ionic
Run the new command
ionic serve
Variable Name: Path
Variable value: C:\Program Files\nodejs\bin
Try adding this to your user and environment variables , and then close the command prompt window and open.
The bin folder needs to be given for both user and environment variables
I got my problem resolved :)
You can uninstall as
npm uninstall -g ionic cordova
then clear cache
npm cache clean -f
then re-install as
npm install -g ionic cordova
Just go to your C:/users/(your name)/node_mudules, and uninstall node_mudules folder. Once uninstalled, open up node js command prompt and type
npm install -g ionic cordova
this worked for me

Grunt serve in Windows, how to?

I have to switched on the second computer which is running on Windows XP.
I clonned my project from repository, which have structure containtng bower.jcon, Gruntfile.js and other following files and is running without problems on second computer with MacOS X.
After that I launched NodeJS command promtp, moved into the directory where application was clonned and i launched commmand.
C:\workspace\myproject>grunt serve
And I got following error message:
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-tasks'
Warning: Task "serve" not found. Use --force to continue.
Whhat I'm doing wrong and how can i solve this issue please?
Many thanks for any help.
EDIT:
I solved it using the following commands:
npm update npm -g
npm install
bower install
grunt serve

Resources