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
I decided to create this issue following #1214 to make a consistent description of yarn's (probably inconsistent) behaviour when dealing with local (file:) dependencies.
If we have dependency in package.json:
"my-local": "file:../relative/path/to/my-local"
I On first install, or when the dependency is added (using yarn add), happens following:
in yarn creates node_modules/my-local and copies the full content of the source folder, then install dependencies that are in my-local/package.json
places in cache *full content (including my-local/node_modules) in the cache under the name like npm-my-local-1.0.0 (considering version in my-local/package.json)
II Then suppose we made some changes to my-local (original source folder):
added some new code
added new dependency
did not change package.json version (1.0.0)
III Then we want to update the content of my-local dependency in the project.
we may do it by yarn upgrade (but will try to upgrade other package) so we do yarn upgrade file:../relative/path/to/my-local or yarn add file:../relative/path/to/my-local, while this yarn does folling:
takes (changed) package.json from original sources my-local folder, parses changed dependencies, links them
then it does strange thing (in my view): it just takes version from cache npm-my-local-1.0.0 and copies its content to our project node_modules/my-local
So you may see inconsistency here - it takes newpackage.json from source and handles dependencies, but takes old content from cache.
IV If we would change the version in my-local/package.json (-> 1.0.1) and would try to upgrade it we would got what wee need:
new version say npm-my-local-1.0.1 would be placed in cache
new content is in project's node_modules/my-local
new dependencies installed
Absolutely the same behaviour is happening when dealing with remote git dependencies: it too checks source package.json (and apppies it) and gets content from cache.
Symlinks problems
As described in #1214 and other issues
Of course we are in a trouble when we use symlinks, when we add local dependency and make simklink /relative/path/to/my-local <==> node_modules/my-local and after upgrade procedure (step III) yarn will replace content for node_modules/my-local (and that means in linked source folder) with a version from cache.
Probably yarn shouldn't be using cache for local ('file:')/ git remote dependencies at all. I consider this as a kind of critical bug in yarn that should be fixed ASAP.
The text was updated successfully, but these errors were encountered:
I'm seeing the same issue with Yarn caching the local folder and ignoring all changes to it until I run yarn cache clean. What's interesting is that the actual dependencies in node_modules reflect the changes to the package.json file in the local folder, but yarn.lock still has the old dependencies listed.
What's interesting is that the actual dependencies in node_modules reflect the changes to the package.json file in the local folder, but yarn.lock still has the old dependencies listed.
I decided to create this issue following #1214 to make a consistent description of yarn's (probably inconsistent) behaviour when dealing with local (
file:
) dependencies.If we have dependency in package.json:
I On first install, or when the dependency is added (using
yarn add
), happens following:node_modules/my-local
and copies the full content of the source folder, then install dependencies that are inmy-local/package.json
my-local/node_modules
) in the cache under the name likenpm-my-local-1.0.0
(considering version inmy-local/package.json
)II Then suppose we made some changes to my-local (original source folder):
package.json
version (1.0.0)III Then we want to update the content of
my-local
dependency in the project.we may do it by
yarn upgrade
(but will try to upgrade other package) so we doyarn upgrade file:../relative/path/to/my-local
oryarn add file:../relative/path/to/my-local
, while this yarn does folling:package.json
from original sourcesmy-local
folder, parses changed dependencies, links themnpm-my-local-1.0.0
and copies its content to our projectnode_modules/my-local
IV If we would change the version in
my-local/package.json
(-> 1.0.1) and would try to upgrade it we would got what wee need:npm-my-local-1.0.1
would be placed in cachenode_modules/my-local
Absolutely the same behaviour is happening when dealing with remote git dependencies: it too checks source package.json (and apppies it) and gets content from cache.
Symlinks problems
As described in #1214 and other issues
Of course we are in a trouble when we use symlinks, when we add local dependency and make simklink
/relative/path/to/my-local <==> node_modules/my-local
and after upgrade procedure (step III) yarn will replace content fornode_modules/my-local
(and that means in linked source folder) with a version from cache.Probably yarn shouldn't be using cache for local ('file:')/ git remote dependencies at all. I consider this as a kind of critical bug in yarn that should be fixed ASAP.
The text was updated successfully, but these errors were encountered: