You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2016-11-24-offline-mirror.md
+13-19
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ categories : announcements
8
8
share_text : "installing node_modules with Yarn offline"
9
9
---
10
10
11
-
Repeatable and reliable builds for large JavaScript projects are vital.
11
+
Repeatable and reliable builds for large JavaScript projects are vital.
12
12
If your builds depend on dependencies being downloaded from network, this build system is neither repeatable nor reliable.
13
13
14
14
One of the main advantages of Yarn is that it can install node_modules from files located in file system.
@@ -19,7 +19,6 @@ Caches store already unzipped tarballs downloaded from registry, they also can b
19
19
The tarballs in “Offline mirror” can be consumed by any version Yarn that will build cache based on them.
20
20
It is also easier to store files when they are compressed.
21
21
22
-
23
22
## Let's set up “Offline mirror” for a simple JS project
24
23
25
24
```json
@@ -36,7 +35,6 @@ It is also easier to store files when they are compressed.
36
35
}
37
36
```
38
37
39
-
40
38
When you run `yarn install`, the generated `yarn.lock` file has sections for every dependency:
41
39
42
40
```yaml
@@ -78,7 +76,7 @@ success Set "yarn-offline-mirror" to "./npm-packages-offline-cache".
78
76
✨ Done in 0.06s.
79
77
```
80
78
81
-
> `./npm-packages-offline-cache` is an example location relative to home folder where all the source`.tar.gz` files will be downloaded to from the registry.
79
+
> `./npm-packages-offline-cache` is an example location relative to home folder where all the source`.tar.gz` files will be downloaded to from the registry.
82
80
83
81
Offline mirror does not come with removing tarballs. In order to keep the cache folder up to date, you need to add the following to the config file:
84
82
@@ -91,7 +89,6 @@ success Set "yarn-offline-mirror-pruning" to "true".
91
89
✨ Done in 0.06s.
92
90
```
93
91
94
-
95
92
This will create a .yarnrc file in your HOME directory.
96
93
Let's move this file to the project root so that offline mirror would be used only for this project.
- Run "yarn install --offline". The offline flag will make sure yarn does not reach out to the network
159
153
160
-
> In a nutshell, to enable “Offline mirror” for your project you need:
161
-
- add “yarn-offline-mirror” configuration to .yarnrc file
162
-
- generate a new yarn.lock with “yarn install” command
154
+
* Clear your global cache with "yarn cache clean"
155
+
* Turn off wifi
156
+
* Run "yarn install --offline". The offline flag will make sure yarn does not reach out to the network
163
157
158
+
> In a nutshell, to enable “Offline mirror” for your project you need:
164
159
160
+
* add “yarn-offline-mirror” configuration to .yarnrc file
161
+
* generate a new yarn.lock with “yarn install” command
165
162
166
163
## A few tips and tricks
167
164
168
165
### Updating your package
169
166
170
167
If you want to make sure you have a clean cached modules, here are few of the steps you can take:
171
-
- Remove the package first. Make sure you have "yarn-offline-mirror-pruning" set to true in your .yarnrc file
172
-
- Clear the yarn cache with "yarn cache clean" before adding the updated version of the package
173
-
- Add your package
174
168
175
-
The "yarn-offline-mirror-pruning" will help clean up any unlinked dependencies. When you add the updated package, it will check the yarn cache first and pull any missing dependencies from there. This will prevent yarn adding new tarball back with the updated package. You want to make sure the yarn cache is all clean before you do any adding for cache module.
169
+
* Remove the package first. Make sure you have "yarn-offline-mirror-pruning" set to true in your .yarnrc file
170
+
* Clear the yarn cache with "yarn cache clean" before adding the updated version of the package
171
+
* Add your package
172
+
173
+
The "yarn-offline-mirror-pruning" will help clean up any unlinked dependencies. When you add the updated package, it will check the yarn cache first and pull any missing dependencies from there. This will prevent yarn adding new tarball back with the updated package. You want to make sure the yarn cache is all clean before you do any adding for cache module.
176
174
177
175
### You can check in “Offline mirror” into git or mercurial repository
178
176
@@ -186,7 +184,6 @@ For example, out of 849 React Native dependencies totaling 23MB, only 10% are la
186
184
Many Facebook teams, including the React Native team, decided to check in their “Offline mirror”.
187
185
They all share the same “Offline mirror” which means that most dependencies for new projects are often already checked into that folder, so the cost of storing the packages in source control gets lower the more projects use it.
188
186
189
-
190
187
### Let's compare checking in node_modules to checking in “Offline mirror”
191
188
192
189
The React Native team used to check in the `node_modules` folder but they hit several limits:
@@ -263,8 +260,6 @@ Untracked files:
263
260
no changes added to commit (use "git add" and/or "git commit -a")
264
261
```
265
262
266
-
267
-
268
263
### Did you know that Yarn is also distributed as a single bundle JS file in [releases](https://github.com/yarnpkg/yarn/releases) that can be used on CI systems without internet access?
269
264
270
265
{:style="max-width: 700px"}
@@ -278,7 +273,6 @@ node ./yarn-0.23.2.js install
278
273
279
274
This is quite convenient for teams that use multiple operating systems and want to have atomic updates for Yarn.
280
275
281
-
282
276
### This is going to get better
283
277
284
278
The “Offline mirror” was implemented early in Yarn's development cycle and we are working on improving it in a backwards compatible way:
Copy file name to clipboardExpand all lines: _posts/2017-05-12-introducing-yarn.md
+1-2
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,6 @@ categories : announcements
8
8
share_text : "Yarn Create & Yarn 1.0"
9
9
---
10
10
11
-
12
11
Last year was a great time for Javascript newcomers! A lot of starter-kit projects were published, refined, and some of them eventually went on to offer command line tools dedicated to make project creation easier. One such example is [create-react-app](https://github.com/facebookincubator/create-react-app), but most frameworks have their own tools, with various flavors and syntaxes.
13
12
14
13
Despite these tools, one problem remains: Users still need to know how to use their package managers before being able to start a new project. They need to know what's the difference between global packages and local packages, and how to make sure that the binaries are available from the shell, which can sometimes cause subtle issues. Further, because these globally installed tools need to be manually updated, most projects maintain a small cli wrapper that downloads the latest version of the tool itself. Fortunately, we're in a position where we can help with this to make building new applications more cohesive:
@@ -25,7 +24,7 @@ When ran, the create command will automatically install or update the requested
25
24
26
25
It is important to us to keep the feature small and extensible. Yarn should be a lightweight tool and `yarn create` is no exception: An immediate implication is that the create command is a completely agnostic tool: we make no assumption regarding what you want to create, and delegate all the behavior to the `create-*` packages! It is our hope that the community will come up with creative way to use this tool. Creating apps is but only one thing! Feel free to make packages that create tests, readmes, changelogs or anything else you want!
27
26
28
-
*Note: The `create-` prefix is inserted right before the package name. So, for example, if you run yarn create `@ng/app`, it will install the `@ng/create-app` package, then run it.*
27
+
_Note: The `create-` prefix is inserted right before the package name. So, for example, if you run yarn create `@ng/app`, it will install the `@ng/create-app` package, then run it._
Copy file name to clipboardExpand all lines: _posts/2017-05-31-determinism.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ supports-color@^3.2.3:
34
34
has-flag "^1.0.0"
35
35
```
36
36
37
-
This is the `yarn.lock`file generated by running the command `yarn add supports-color`. This file contains the version of supports-color that our project is using as well as the exact version of all its sub-dependencies.
37
+
This is the `yarn.lock`file generated by running the command `yarn add supports-color`. This file contains the version of supports-color that our project is using as well as the exact version of all its sub-dependencies.
38
38
39
39
With this lock file we can ensure that the version of `has-flag` that `supports-color` relies on is always the same version.
40
40
@@ -80,7 +80,7 @@ npm 5 introduces a rework of the shrinkwrap feature called package-lock. This fi
80
80
}
81
81
```
82
82
83
-
Note that here all the packages listed in the first dependencies object are hoisted. This means that npm can use only the package-lock as the source of truth in order to build the final dependency graph whereas Yarn needs the accompanying`package.json` to seed it.
83
+
Note that here all the packages listed in the first dependencies object are hoisted. This means that npm can use only the package-lock as the source of truth in order to build the final dependency graph whereas Yarn needs the accompanying`package.json` to seed it.
84
84
85
85
This means that npm has better assurances around hoisting position across npm versions at the cost of having a more dense lockfile. There’s currently no plan on how to support `package-lock.json` in Yarn as the story around lockfile interoperability is unclear. You could however imagine a future where Yarn supports both and updates them in tandem. We’re very interested in community feedback and encourage proposals for how this would work to be submitted as an [RFC](https://github.com/yarnpkg/rfcs).
Copy file name to clipboardExpand all lines: _posts/2017-06-16-supporting-more-registries.md
-1
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,6 @@ categories : announcements
8
8
share_text : "Yarn now supports even more private registries"
9
9
---
10
10
11
-
12
11
Today, Yarn already supports a wide variety of different package feeds when fetching and downloading your dependencies. Up until now, there was however a small subset of public and private package feed providers that Yarn could not yet handle very well. One example of these package feed providers that were not yet supported was [Visual Studio Team Services](https://www.visualstudio.com/team-services/) (VSTS).
Copy file name to clipboardExpand all lines: _posts/2017-06-19-adding-command-line-aliases-for-yarn.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Let’s say you check for package distribution tags information pretty often, ar
16
16
17
17
## Bash & Zsh
18
18
19
-
[Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)) is the default shell on most Unix-like systems; together with [Zsh](https://en.wikipedia.org/wiki/Z_shell), they both descended from the earlier [Bourne shell](https://en.wikipedia.org/wiki/Bourne_shell) and hence syntaxes are largely compatible. To add a simple alias in either Bash or Zsh, simply have the following line added into your `.bashrc` or `.zshrc`, respectively:
19
+
[Bash](<https://en.wikipedia.org/wiki/Bash_(Unix_shell)>) is the default shell on most Unix-like systems; together with [Zsh](https://en.wikipedia.org/wiki/Z_shell), they both descended from the earlier [Bourne shell](https://en.wikipedia.org/wiki/Bourne_shell) and hence syntaxes are largely compatible. To add a simple alias in either Bash or Zsh, simply have the following line added into your `.bashrc` or `.zshrc`, respectively:
0 commit comments