yarn, npm, nodejs distinguished relations

Yarn is a Facebook company produced a software package for managing nodejs. Yarn to make up for some shortcomings of the emergence of npm.
npm is accompanied nodejs package management tools installed together.

Xz installation nodejs through official documents.

Installation nodejs

Xz file is downloaded

xz -d node-v12.14.0-linux-x64.tar.xz
tar -vxf node-v12.14.0-linux-x64.tar
sudo mv node-v12.14.0-linux-x64 /usr/local
sudo vim /etc/profile
# nodejs
export NODE_HOME=/usr/local/node-v12.14.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile
# node -v
v12.14.0
# npm -v
6.13.4

No need to install!

Comes npm!

Installation yarn

Installation curl

sudo apt install curl

Add key

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

Add Source

sudo sh -c 'echo "deb https://dl.yarnpkg.com/debian/ stable main" >> /etc/apt/sources.list.d/yarn.list'

Refresh installation

sudo apt update
sudo apt install yarn

View version (you must have installed nodejs, can view)

yarn --version

Otherwise it will error

# yarn --version
/usr/share/yarn/lib/cli.js:46099
  let {
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/share/yarn/bin/yarn.js:24:13)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

Guess you like

Origin www.cnblogs.com/jiqing9006/p/12161488.html