Open mxschmitt opened 2 years ago
@darcyclarke @isaacs Should we treat workspaces like a local registry? I'm leaning toward yes. This way, publishing a root package with spec'd dependencies that are a workspace will work for local dev and after being published when workspaces aren't vendored.
Additionally, I'm using lerna 4 (with hoisting) to update versions of packages/*/package.json
in a monorepo for release purposes. After updating package versions using lerna, the root package-lock.json
seems to no longer work, especially if no node_modules
is present (likely in a CI environment).
Deleting and rebuilding the package-lock.json
is the only way I've found to get around this issue
~I actually just ran into this myself and it appears to be a regression between npm@7.20.2
(running npm i
updates package-lock.json
with bumped workspace package versions) and npm@7.20.3
(doesn't install, ETARGET
error as above) in case that helps debug or get someone around the issue.~ Oh oops, never mind me, it's as @CITguy described above.
didn't experience this issue on latest npm version (currently 8.5.1), so this might've been silently resolved and it's safe to close this issue?
If this isn't the same underlying problem, please let me know and I will open a new issue.
When running npm version <v> -ws
, only the "version" field in my packages is updated. A given package's dependency on another workspaces-aware-local package is not updated.
$ npm -v
9.5.1
$ npm init --yes
$ npm init -w ./packages/a --yes
$ npm init -w ./packages/b --yes
$ npm i --save b -w ./packages/a/
$ npm --workspaces --no-git-tag-version version major
$ cat packages/*/package.json
{
"name": "a",
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"b": "^1.0.0"
}
}
{
"name": "b",
"version": "2.0.0",
"description": "",
"main": "index.js",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
And, yes, package-lock is also not updated
cat package-lock.json
{
"name": "xworkspaces",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "xworkspaces",
"version": "1.0.0",
"license": "ISC",
"workspaces": [
"packages/a",
"packages/b"
]
},
"node_modules/a": {
"resolved": "packages/a",
"link": true
},
"node_modules/b": {
"resolved": "packages/b",
"link": true
},
"packages/a": {
"version": "2.0.0",
"license": "ISC",
"dependencies": {
"b": "^1.0.0"
}
},
"packages/b": {
"version": "2.0.0",
"license": "ISC",
"devDependencies": {}
}
}
}
I also tried, unsuccessfully, to get this working on the latest 8.x.x release, 18.19.4
at the time of writing. There I hit some other issues which have been reported elsewhere which related to my packages being private or unpublished.
If anyone has a clever workaround, please lmk. I'm trying to move away from lerna
and this problem is the only real blocker.
Is there an existing issue for this?
Current Behavior
Expected Behavior
It prioritises the package from the workspaces over the NPM registry
Steps To Reproduce
See here for a small repro https://github.com/mxschmitt/npm-bump-version-etarget and instructions.
Relates https://github.com/npm/cli/issues/3403 but this one is only about updating, mine is about installing.
Environment