- Visit ben awad's tutorial: https://youtu.be/G8KXFWftCg0
- Git repo: https://github.com/sahilrajput03/yarn-workspaces-example
- ❤️ You can refer your snippets in your github repo:
config/snipsfor your yarn snippets as well.
LEARN: Use ctrl+p and ctrl+n for switching to previous and next commands in bash.
LEARN: MOVING TO YARN PERMANENTLY # renamed /c/nodejs/'s npm and npm.cmd # _npm and _npm.cmd files.
LEARN: YARN does use package-lock.json file for installing exact dependencies it used in last installation of package.
yarn release article - @ engineering.fb.com
yarn start # For npm start
yarn init # Initialize new project.
yarn or yarn install # Install all dependencies.
yarn add [pkg] # Installs latest avalable version.
yarn add [pkg] --dev # Installs as dev dependency. # Or: yarn add -D [pkg]
yarn remove [pkg] # Removes a dependecy.
yarn global add [pkg] # Installs globally.
yarn add [pkg@someVersion] # Installs specific version.
yarn add [pkg] --peer
yarn add [pkg] --optional
yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]yarn version --major # Instead of npm version major
yarn version --minor # Instead of npm version minor
yarn version --patch # Instead of npm version patch
yarn login #This is only executable on cmd(so use win+n 11 for cmd in conemu) and it'll need your npm username and npm email address to be able to publish( via `yarn publish`).
yarn publish # Publishes to npm registry, but good thing is it instanly shows up on yarn registry(YIKES) and for npm it is as usual, like it takes around 1-2 minute to actually see it on their site.
Unortunately yarn unpublish doens't exists
so use:
_npm unpublish <pkg-name> -f # Will remove complete project fom npm registry.
_npm unpublish <pkg-name>@ver # Will remove particular version from npm registry.
Source : Migrating from npm @ yarnpkg.com
Source : Pubish @ yarnpkg.com
{
"name": "my-package",
"scripts": {
"build": "babel src -d lib",
"test": "jest"
}
}yarn [script-name] # Or yarn run [script-name]
yarn start
yarn script2 # Works perfectly.
yarn run test -o --watch
# would run below command -
jest -o --watch.Source : yarn run @ yarnpkg.com
# Checking installed version of yarn
yarn -v
yarn --versionUpdating yarn
npmBackup i -g yarn
#verify installed version by - yarn -v or yarn --version
Peer dependencies are a special type of dependency that would only ever come up if you were publishing your own package.
Having a peer dependency means that your package needs a dependency that is the same exact dependency as the person installing your package. This is useful for packages like react that need to have a single copy of react-dom that is also used by the person installing it.
Source - Amazing Guide @ yarnpkg.com
yarn upgrade [pkg]
Source: Docs @ yarnpkg.com
There are times when we don't want to npm run someShit or npm start for a current directory but for a custom directory, say if you lazy enought to cd and do npm run or npm start, in those cases you
- You can use
npm start -C <directoryHere>or `npm start --prefix , src@stackoverflow and look for --prefix there.., and also there's stackoverflow for the same src@officialDocs. - If using yarn, you can use --cwd for e.g.,
yarn --cwd <directoryHere> startoryarn --cwd someRunScript. Docs for same here.