I just installed Ubuntu 20.04 and I'm finding it really difficult to use global packages like yarn and expo-cli. I successfully installed nodejs but while installing yarn I got this error EACCES: permission denied, access '/usr/lib/node_modules' and managed to fix it with the solution provided here and successfully installed yarn. I tested to see if it worked with yarn --version and it did, but after closing and re-opening the terminal and doing this yarn --version again, I get this Command 'yarn' not found, but can be installed with:
sudo apt install cmdtest. If I try installing yarn again, I get this
/home/tony/.npm-global/bin/yarn -> /home/tony/.npm-globa/lib/node_modules/yarn/bin/yarn.js
/home/tony/.npm-global/bin/yarnpkg -> /home/tony/.npm-global/lib/node_modules/yarn/bin/yarn.js
+ yarn#1.22.4
updated 1 package in 3.177s
Notice that yarn doesn't installed but rather updated, I've tried different solutions but still can't fix it. This also happens when I try to install expo-cli. I don't know much about Ubuntu and confused as to what to do now.
A simple restart seemed to fix it. I think one of the solutions I tried fixed the issue but only required a restart.
This happens when I run expo install expo-permissions
It explicitly returns me
Installing 1 SDK 35.0.0 compatible native module using Yarn.
yarn add expo-permissions#~7.0.0
spawn yarnpkg ENOENT
Set EXPO_DEBUG=true in your env to view the stack trace.
Which is strange because I don't normally use Yarn. I use NPM to install dependencies.
I know this error has to do with my files or some path not being configured correctly. What I don't know is which path it is that I have to change and how to do so.
Please let me know if there is any other relevant info that I should add here.
I had the same problem as you my solution and you perform the installation of yarn via npm:
npm i -g yarn
I believe this error is caused because he cannot find the symbolic link for yarnpkg. When executing this command, yarn will be updated and linked.
You can just pass the flag --npm after the command.
expo install [package-name] --npm
Best solution for this would be using --npm flag
Example:
expo install pkname --npm,
expo update --npm,
expo upgrade --npm,
This is happened because you haven't executed yarn install or yarn command.
Yes, I tried many ways and finally, I found the solution.
The issue was different yarn package version.
So first of all, you need to upgrade yarn version lastest.
open terminal and type the following.
npm install --global yarn
expo update
Hope this solve your issue.
I had a similar problem. You should install yarn in your system, since that's what Expo CLI is trying to execute to install packages. For me my issue was that I did had yarn but I had an old version. I had to update my yarn version to 1.19.0. If you install this version it should work correctly.
I recommend using yvm to install and manage different versions of yarn. After you install yvm it is as easy to install yarn as yvm install <version>, so in this case you would do yvm install 1.19.0. And if you ever have to change versions because another project doesn't work with 1.19.0 (sometimes it happens) you can just install another version and change between versions by doing yvm use <version>.
Hope this helps!
This worked for me:
Latest Yarn Installation (from here)
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 update && sudo apt install yarn
sudo apt update && sudo apt install --no-install-recommends yarn
Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
In the terminal, log in and log out for the changes to take effect
yarn --version checks if the version is latest (1.0+).
Then expo update <version> (ex: 36.0.0)
Concideration:
Do not forget to check if you give attention to similar warning: "warning package-lock.json found. Your project contains lock files generated by tools other than Yarn."
"spawn yarnpkg ENOENT" usually indicates that the system cannot find the "yarnpkg" command.
npm i -g corepack
This worked for me.
For nextjs you can try this as I found out that I am npx not yarn same as how I start npx expo start
npx expo update
I'm a newbie using the terminal and npm and I’m having issues installing Vapid CMS via terminal on Mac.
I tried both with and without sudo but I get error messages on both cases. When I try npm install -g #vapid/cli this is the error I get:
https://ibb.co/MDQhkNL
The given command 'npm install -g #vapid/cli' doesn't work for me, but I assume it might be a problem of permission.
Found this which indicates that, if you go for sudo npm i -g #vapid/cli --unsafe-perm it should install. I wind up with an error in the installation of sharp after that, though; YMMV. Granted, the WWD guy is using WSL and I'm running Ubuntu, so neither of these answers might be pertinent to MacOS, but it might get you a step farther.
How can I uninstall yarn? I've used it for a react-native project and now whenever I move the code out of index.ios.js or index.android.js it throws an error so I'd like to just use npm but whenever I initialize a react-native project it defaults to yarn. I tried npm uninstall yarn but that didn't work. Thanks.
Depends on how you installed it:
brew: brew uninstall yarn
tarball: rm -rf "$HOME/.yarn"
npm: npm uninstall -g yarn
ubuntu: sudo apt-get remove yarn && sudo apt-get purge yarn
centos: yum remove yarn
windows: choco uninstall yarn (or go to control panel > add/remove programs and uninstall it from there)
Try this, it works well on macOS:
$ brew uninstall --force yarn
$ npm uninstall -g yarn
$ yarn -v
v0.24.5 (or your current version)
$ which yarn
/usr/local/bin/yarn
$ rm -rf /usr/local/bin/yarn
$ rm -rf /usr/local/bin/yarnpkg
$ which yarn
yarn not found
$ brew install yarn
$ brew link yarn
$ yarn -v
v1.17.3 (latest version)
Or you could install it as recommended on the website (https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable) through npm using:
$ npm install --global yarn
Didn't see the answer that worked for me, so here it is: On my OSX system I found yarn at ~/.yarn/bin/yarn. rm -rf ~/.yarn took care of it.
on windows: Go to "Add or remove programs" in control panel (or open the start menu and search for "remove program")
https://github.com/yarnpkg/yarn/issues/3331
If you are using corepack and previously ran the command corepack enable, then you can uninstall yarn via the following command:
corepack disable yarn
If you installed with brew, try brew uninstall yarn at terminal prompt. Also remember to remove yarn path info in your .bash_profile.
I'm using macOS. I had a few versions of yarn installed with Homebrew, which I uninstalled with brew uninstall --force yarn. I then installed the latest version 1.7.0 of Yarn using Homebrew brew install yarn
But still when I ran which yarn, it returned /Users/Me/.yarn/bin/yarn, and yarn --version returned 0.24.6. There was no mention of Yarn in ~/.bash_profile, but my ~/.bashrc file contained the line export PATH="$HOME/.yarn/bin:$PATH" indicating that I must have previously installed Yarn globally, but I only wanted to use the latest version that I just installed with Homebrew.
So I uninstalled Yarn globally by running npm uninstall -g yarn; rm -rf ~/.yarn, then editing the file ~/.bashrc by changing the line to export PATH="/usr/local/bin/yarn:$PATH" and running source ~/.bashrc to update the PATH in the terminal session. Then when I ran which yarn it returned /usr/local/bin/yarn, and when I ran yarn --version it returned
1.7.0
In case you installed yarn globally like this
$ sudo npm install -g yarn
Just run this in terminal
$ sudo npm uninstall -g yarn
Tested now on my local machine running Ubuntu. Works perfect!
I tried the Homebrew and tarball points from the post by sospedra. It wasn't enough.
I found yarn installed in: ~/.config/yarn/global/node_modules/yarn
I ran yarn global remove yarn. Restarted terminal and it was gone.
Originally, what brought me here was yarn reverting to an older version, but I didn't know why, and attempts to uninstall or upgrade failed.
When I would checkout an older branch of a certain project the version of yarn being used would change from 1.9.4 to 0.19.1.
Even after taking steps to remove yarn, it remained, and at 0.19.1.
What I've done on my side:
Went to the /usr/local/lib/node_modules, and deleted the yarn folder inside it.
I couldn't uninstall yarn on windows and I tried every single answer here, but every time I ran yarn -v, the command worked. But then I realized that there is another thing that can affect this.
If you on windows (not sure if this also happens in mac) and using nvm, one problem that can happen is that you have installed nvm without uninstalling npm, and the working yarn command is from your old yarn version from the old npm.
So what you need to do is follow this step from the nvm docs
You should also delete the existing npm install location (e.g. "C:\Users<user>\AppData\Roaming\npm"), so that the nvm install location will be correctly used instead. Backup the global npmrc config (e.g. C:\Users<user>\AppData\Roaming\npm\etc\npmrc), if you have some important settings there, or copy the settings to the user config C:\Users<user>.npmrc.
And to confirm that you problem is with the old npm, you will probably see the yarn.cmd file inside the C:\Users\<user>\AppData\Roaming\npm folder.
npm uninstall yarn removes the yarn packages that are installed via npm but what yarn does underneath the hood is, it installs a software named yarn in your PC. If you have installed in Windows, Go to add or remove programs and then search for yarn and uninstall it then you are good to go.
For Windows User:
Just use the installer file(i.e yarn-1.22.4.msi in my case) to uninstall yarn.
Once you open the installer you will get three options, i.e to install, repair and uninstall yarn from your machine.
Select uninstall and it will remove all the yarn files from your pc.
For windows user:
npm uninstall -g yarn
For Mac user:
$ npm uninstall -g yarn
It will completely be remove yarn for your system.
If on your system, Yarn is provided from Node.js, through corepack, then, you can choose which version of Yarn you want to use, with the following:
corepack prepare yarn#x.y.z --activate
–as per https://nodejs.org/api/corepack.html#upgrading-the-global-versions
On my Mac neither of these regular methods to uninstall Yarn worked:
brew: brew uninstall yarn
npm: npm uninstall -g yarn
Instead I removed it manually by typing rm -rf ~/.yarn (thanks user elthrasher) and deleting the two symbol links yarn and yarnpkg from usr/local/bin.
Afterwards brew install yarn gave me the latest version of Yarn.
Background: The fact that I had a very outdated version of Yarn installed gave me utterly incomprehensible errors while trying to install additional modules to a project set up with Vue CLI Service and Vue UI, which apparently uses Yarn 'under the hood'. I generally use NPM so it took me a while to figure out the cause for my trouble. Naturally googling error messages produced by such module incompatibilities presented no clues. With Yarn updated everything works just perfectly now.
If you are still getting errors after deleting ~/.yarn about files not being found, don't forget to delete the yarn rc file:
rm ~/.yarnrc.yml
This is how to uninstall yarn completely for Mac Users
sudo npm uninstall -g yarn
In the case of windows, after executing npm uninstall -g yarn, still if yarn did not uninstalled, then go to "C:\Users\username\AppData\Local" and remove the yarn folder.
Close the cmd and reopen the cmd and execute yarn . it will give you message 'yarn' is not recognized as an internal or external command, operable program or batch file.
Try "npm uninstall -g yarnpkg"(global) or "npm uninstall yarnpkg"(local) if you installed it with npm.
That's what worked for me.
If that still doesn't work and you installed it with npm, do "npm list -g" to check if you installed it globally or "npm list" if you installed it locally. Hope that helps anyone having this problem. :D
EDIT: Found something if you installed yarn with .msi executable you have to install it the normal windows way.
I had to manually remove(delete) the Yarn folder from drive and then run npm uninstall -g yarn again to reinstall it. It worked for me.
For Windows:
I need to do these steps to completely remove the yarn from the system.
Go to add or remove programs and then search for yarn and uninstall it(if you installed it with the .msi)
npm uninstall -g yarn (if you installed with npm)
Remove any existing yarn folders from your Program Files (x86) (Program Files (x86)\Yarn).
Also need to delete your Appdata\local\yarn folder ( type %LOCALAPPDATA% in the run dialog box (win+R), it opens a local folder and there you'll find the yarn folder to delete)
Finally,check your user directory and remove all .yarn folder, .yarn.lock file, .yarnrc etc ( from C:\Users\<user>\)
remove yarn
# macOS & brew
$ brew uninstall yarn
remove npm package
# yarn global remove
$ sudo yarn global remove #tarojs/cli
# yarn global add
$ sudo yarn global add #tarojs/cli
refs:
https://classic.yarnpkg.com/en/docs/cli/global/
https://classic.yarnpkg.com/en/docs/cli/remove/
It really works when I'm still getting errors after deleting ~/.yarn
rm ~/.yarnrc.yml
We must delete .yarnrc.yml or .yarnrc file
I found the other answers a bit inadequate since I wanted to "completely" remove yarn from my Mac (M1). I found this worked:
First remove it how you installed it i.e. same as this.
Remove the cache. For example on my Mac I ran:
rm -rf ~/Library/Caches/Yarn
Remove the global node_modules cache of Yarn:
rm -rf ~/.config/yarn
yarn cache clean did not help get rid of the above which tool significant space.
Remove any other Yarn-related config files:
rm -rf ~/.yarn
rm ~/.yarnrc
ng set --global packageManager=npm OR ng set --global packageManager=yarn
Just copy this command and your problem will be fixed.
npm uninstall yarn
searched, and did not see this specific problem.
Trying to get a MEAN stack built on my Linux Mint machine, and bumping into a bit of an unusual issue.
Got MongoDB installed, and finally got it running correctly (none of the instructions ANYWHERE mentioned having to create the /data/db/ directory and set permissions, go figure).... it works now.
Got NodeJS installed, and it appears to work correctly.
I had been told (apparently incorrectly) that NPM installs right alongside Node, with:
sudo apt-get install nodejs
but:
$ npm
bash: /usr/bin/npm: No such file or directory
So I go ahead and install NPM separately.
$ sudo apt-get install npm
Seems to work, so far, no errors, and it looks like it is pulling down the NPM package and installing it...
$ nodejs -v
v0.10.21
$ npm -v
$
?? It simply fails to respond without any error... so I try:
$ npm install grunt -g --save-dev
$
Same completely silent failure... in fact, NOTHING I could do gets a response out of NPM.
Looked all over the web, and saw nothing similar anywhere... found out that NPM holds its cache files in ~/.npm and noticed that this folder didn't exist (kinda like the mongo issue above), so I created it, and set permissions to 7777... still nothing.
Purged and re-installed both node and npm, tried installing them both together and separately (yes, desperation)... still no love.
WTF am I doing wrong?
I would love, eventually, to have a nice development environment setup, hopefully with Cloud9 as a local IDE.... but already pulling my hair out.
=========================================================================================
OK, after a few more headaches, this is up and built now... thank you all.
Would love to mark both as answers, but it won't let me.
npm does come with node. Where is apt-get pulling it from? I install the Mac OS X packages on my Mac for development and npm does in fact come with it. I compile from source on my CentOS server and npm comes with it.
Your package provider may be providing them separately as a (in)convenience to you.
As for why your npm command does not work after installation, I can't say for sure, but I am suspicious of your use of --save-dev and -g together.
-g means to install globally, which means 2 things:
It will be installed outside of your npm package's structure into a system location like /usr/bin or /usr/local/bin
It requires root access to install. Did you use sudo to run it with root access?
Both of those requirements conflict with --save-dev which records the package as a dependency in your package.json file so that future npm install commands will install that package within the project space.
That said, I happen to know a lot about grunt. It has 2 parts, a globally installed tool and the package-specific tool. The correct way to install it is:
$ [sudo] npm install -g grunt-cli
$ npm install grunt --save-dev
This will install the grunt-cli package into a system location guaranteed to be in the $PATH, which turns around and looks for a package-specific grunt installed which is not system-wide.
When installing nodejs with npm, this one-liner worked for me.
sudo apt-get install nodejs nodejs-dev npm
I don't believe npm comes with the nodejs installation in the apt repo. Try to install npm separately using the following tutorial http://www.giantflyingsaucer.com/blog/?p=1688 'To install NPM ....'
====== Edit ====
node and npm IS separate. Follow the official wiki and everything should be fine