Reputation: 61
I try to add a package (not published) in my project in offline mode.
I configured the yarn-offline-mirror in the yarnrc of my project :
yarn-offline-mirror "./yarn-offline-mirror"
I modify manually the package.json :
"dependencies": {
"@xxx/yyy": "1.0.0",
}
I packed my package : yarn pack --filename @xxx/[email protected]
I moved manually the package @xxx/[email protected] in the folder "yarn-offline-mirror" of my project.
I run in my project :
yarn install --offline
I obtain :
error Couldn't find any versions for "@xxx/yyy" that matches "1.0.0" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
If I publish and install my package @xxx/[email protected] in my project (in online mode) and after, I reinstall in offline mode with yarn-offline-mirror, it works.
But I want pack and add my package @xxx/[email protected] in my project without publish my package (in the case where I have no internet connection).
Upvotes: 4
Views: 11897
Reputation: 450
I am pretty sure you have followed the blog which contains all the steps.
I followed it as well, there is an important point it is not obvious.
The yarn-offline-mirro
is based on yarn.lock
file (which is auto-generated after you run yarn install
). That is key relevant point in the procedure and was not well highlighted in the blog post.
Install your package as whatever other package in "online" mode with yarn install
and you will see the packages .tgz
are in your [off-line-folder]
, then you can delete [node_modules]
in your project folder eventually you can execute yarn cache clean
or even move you offline, but NEVER delete the yarn.lock
.
After that, yarn install --offline
should work as expected.
Upvotes: 5