-
I'm a bit confused about the recommended install method (https://yarnpkg.com/getting-started/install)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The As for git etc, Yarn now does a bit more of what you would typically have to do yourself when bootstrapping a project. It doesn't install hooks, it just runs |
Beta Was this translation helpful? Give feedback.
-
Just to add to this as the "install" method was a bit confusing to me as well. It's initializing a new project, hence adding all those extra files in the directory when you run the command. Instead if you know the version you want to use, you can either add that per-project with # Example environment to start from:
$ docker run --rm -it --workdir /tmp node:20-bookworm-slim bash
$ yarn -v
1.22.19
# You want to run these commands to install / upgrade yarn:
$ corepack enable
$ corepack prepare yarn@stable --activate
$ yarn -v
3.6.3 As you can see the Personally, the above is nicer than the official yarn docs $ docker run --rm -it --workdir /tmp node:20-bookworm-slim bash
$ yarn -v
1.22.19
$ yarn init -2
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.6.3/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.6.3.cjs
➤ YN0000: Done in 0s 411ms
{
name: 'tmp',
packageManager: '[email protected]'
}
Internal Error: Process git failed to spawn
at ChildProcess.<anonymous> (/tmp/.yarn/releases/yarn-3.6.3.cjs:392:5563)
at ChildProcess.emit (node:events:514:28)
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
error Command failed.
Exit code: 1
Command: /usr/local/bin/node
Arguments: /opt/yarn-v1.22.19/bin/yarn.js init -2
Directory: /tmp
Output:
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
$ ls -la
total 48
drwxrwxrwt 1 root root 4096 Sep 21 04:46 .
drwxr-xr-x 1 root root 4096 Sep 21 04:46 ..
-rw-r--r-- 1 root root 134 Sep 21 04:46 .editorconfig
-rw-r--r-- 1 root root 142 Sep 21 04:46 .gitattributes
-rw-r--r-- 1 root root 251 Sep 21 04:46 .gitignore
drwxr-xr-x 3 root root 4096 Sep 21 04:46 .yarn
-rw-r--r-- 1 root root 40 Sep 21 04:46 .yarnrc.yml
-rw-r--r-- 1 root root 6 Sep 21 04:46 README.md
-rw-r--r-- 1 root root 54 Sep 21 04:46 package.json
drwxr-xr-x 1 root root 4096 Sep 11 17:21 v8-compile-cache-0
-rw-r--r-- 1 root root 0 Sep 21 04:46 yarn.lock
$ yarn -v
3.6.3 |
Beta Was this translation helpful? Give feedback.
The
-2
flag is an alias for--install stable
, ie it runsyarn init
w/ the latest version of Yarn, even if you run it from a 1.x binary. I think we'll likely look at making it the default once the 4.0 ships.As for git etc, Yarn now does a bit more of what you would typically have to do yourself when bootstrapping a project. It doesn't install hooks, it just runs
git init
.