Search code examples
node.jsnpmyarnpkgexpo

Global packages successfully installs and works but stops working after terminal restart


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.


Solution

  • A simple restart seemed to fix it. I think one of the solutions I tried fixed the issue but only required a restart.