Yarn: Offline mode is not working

Created on 6 Mar 2018  ยท  7Comments  ยท  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

Bug

What is the current behavior?
Everything is working for internet machine to install even no active internet connection. However, when the global cache is clean the offline installation will not work.

If the current behavior is a bug, please provide the steps to reproduce.

1) Create directory under temp C:\temp\project
2) Create package.json under c:\temp\project (see package.json.zip)
package.json.zip
3) Command line: yarn config set yarn-offline-mirror C:\npm-packages-offline-cache
4) Command line: yarn config set yarn-offline-mirror-pruning true
5) Move C:\Users\[my name]\.yarnrc into C:\temp\project
6) yarn install (install will be successful)
7) yarn cache clean
throws error but still able to clean:
error An unexpected error occurred: "EPERM: operation not permitted, mkdir 'C:\Users\[my name]\AppData\Local\Yarn\Cache\v1'".
info If you think this is a bug, please open a bug report with the information provided in "C:\temp\project\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/cache for documentation about this command.
8) disable network devices/unplugged cable
9) yarn install --offline
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "Can't make a request in offline mode (\"https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz\")".
info If you think this is a bug, please open a bug report with the information provided in "C:\temp\project\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the expected behavior?
It should install offline extracting packages from C:\npm-packages-offline-cache

Please mention your node.js, yarn and operating system version.
Node: v9.7.1 x64
Yarn: v1.5.1
OS:
Microsoft Windows 8 [Version 6.3.9600]
Microsoft Windows 7 [Version 6.1.7601]

triaged

Most helpful comment

NixOS, not working.

All 7 comments

It's working OK for me on OSX:

~/Projects/yarn-test ๐Ÿ’   yarn -v
1.5.1

~/Projects/yarn-test ๐Ÿ’   cat package.json
{
  "name": "foresight.client.2",
  "version": "1.0.0",
  "main": "fs2.js",
  "author": "moi.villa.team",
  "license": "MIT",
  "dependencies":{
    "gulp": "^3.9.1",
  "gulp-autoprefixer":"^5.0.0",
  "gulp-changed":"^3.2.0",
  "gulp-clean":"^0.4.0",
  "gulp-concat":"^2.6.1",
  "gulp-jshint":"^2.1.0",
  "gulp-load-plugins":"^1.5.0",
  "gulp-minify-css":"^1.2.4",
  "gulp-minify-html":"^1.0.6",
  "gulp-ng-annotate":"^2.1.0",
  "gulp-sourcemaps":"^2.6.4",
  "gulp-strip-debug":"^3.0.0",
  "gulp-uglify":"^3.0.0",
  "jshint":"^2.9.5",
  "jshint-stylish":"^2.2.1",
  "karma":"^2.0.0",
  "karma-chrome-launcher":"^2.2.0",
  "jasmine-core":"^3.1.0",
  "jasmine":"^3.1.0",
  "karma-jasmine":"^1.1.1",
  "jasmine-ajax":"^3.3.1",
  "jasmine-jquery":"^2.1.1",
  "gulp-jasmine":"^3.0.0",
  "karma-cli":"^1.0.1",
  "jasmine-reporters":"^2.3.0"
  }
}

~/Projects/yarn-test ๐Ÿ’   cat .yarnrc
yarn-offline-mirror "./npm-packages-offline-cache"
yarn-offline-mirror-pruning true

~/Projects/yarn-test ๐Ÿ’   yarn
yarn install v1.5.1
info No lockfile found.
[1/4] ๐Ÿ”  Resolving packages...
warning gulp > [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
warning gulp > vinyl-fs > [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
warning gulp > vinyl-fs > glob-stream > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning gulp > vinyl-fs > glob-stream > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning gulp > vinyl-fs > glob-watcher > gaze > globule > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning gulp > vinyl-fs > glob-watcher > gaze > globule > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning gulp > vinyl-fs > glob-watcher > gaze > globule > glob > [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
warning [email protected]: Please use gulp-clean-css
warning gulp-minify-css > [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
warning gulp-minify-html > [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
warning gulp-minify-html > minimize > [email protected]: Use uuid module instead
warning karma > log4js > [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
warning karma > log4js > loggly > request > [email protected]: Use uuid module instead
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
โœจ  Done in 30.13s.

~/Projects/yarn-test ๐Ÿ’   yarn cache clean
yarn cache v1.5.1
success Cleared cache.
โœจ  Done in 9.89s.

{turned off wifi at this point. ping to prove it.}
~/Projects/yarn-test ๐Ÿ’   ping google.com
ping: cannot resolve google.com: Unknown host

~/Projects/yarn-test ๐Ÿ’   yarn install --offline
yarn install v1.5.1
[1/4] ๐Ÿ”  Resolving packages...
success Already up-to-date.
โœจ  Done in 0.56s.

~/Projects/yarn-test ๐Ÿ’   rm -rf node_modules/

~/Projects/yarn-test ๐Ÿ’   yarn install --offline
yarn install v1.5.1
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
โœจ  Done in 18.28s.

If you look in C:\npm-packages-offline-cache are the package files in there?

For a while if the install had already been done, then you added the offline mirror and ran yarn install again, it would just say "up to date" and not populate the offline mirror directory. You had to delete node_modules and do the install, or have the offline mirror option set before the first install. You have it in the right order in your steps above, but it's worth checking in C:\npm-packages-offline-cache to make sure the files are there.

If you look in C:\npm-packages-offline-cache are the package files in there?
Yes.

Yes I delete node_modules, yarn cache clean and disconnect from network. yarn install --offline does not work without the previous cache entries (default location: C:\Users[username]\AppData\Local\Yarn\Cache\v1).

For what I understand, it will retrieve and extract all packages from C:\npm-packages-offline-cache and dump in to cache folder. Then, the installation will proceed.

Doesn't work with me either, getting the same error as the OP and I'm on win10.

NixOS, not working.

Got the same Error on OSX.

@altyne @kaylie-alexa is there an update on this? Is the bug no longer there? Is there any progress on this issue?

@all this is working in latest version of yarn. Follow the instruction https://classic.yarnpkg.com/blog/2016/11/24/offline-mirror/. In addition, copy the packages and cache contents.

When installing offline, use 'yarn install --offline'

Was this page helpful?
0 / 5 - 0 ratings