Skip to content

[BUG] Can not install local package in a workspace. Local package name and version affects resolution. #4379

@iSuslov

Description

@iSuslov

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Create a folder and run:

npm init -y
npm init -w packages/a -y
npm init -w packages/b -y
npm init -w packages/c -y
npm init -w packages/z -y
npm i b@1.0.0 -w a
npm i c@1.0.0 -w a
npm i z@1.0.0 -w a

Every line completes without errors except last one. At the end you will get:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for z@1.0.0.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

Local packages b and c were successfully added to the local package a. Adding package z raised error.

It turns out that if there is no package with such name and version in the nmp registry, it will fail to install local package.

Expected Behavior

I should be able to install any local packages inside my workspace regardless of remote package with the same name and version being or NOT being presented in the remote npm repository.

Steps To Reproduce

  1. In an empty folder run:
npm init -y
npm init -w packages/a -y
npm init -w packages/b -y
npm init -w packages/c -y
npm init -w packages/z -y
npm i b@1.0.0 -w a
npm i c@1.0.0 -w a
npm i z@1.0.0 -w a

Environment

  • npm: 8.1.2, 8.1.4
  • Node.js: v16.13.1, v17.0.1
  • OS Name: macOS Monterey
  • System Model Name: Macbook Pro M1
  • npm config:
; node bin location = /Users/user/.nvm/versions/node/v17.0.1/bin/node
; cwd = /Users/user/Projects/delete_me/npm_workspaces_problem
; HOME = /Users/user
; Run `npm config ls -l` to show all defaults.
; "default" config from default values

_auth = (protected) 
access = null 
all = false 
allow-same-version = false 
also = null 
audit = true 
audit-level = null 
auth-type = "legacy" 
before = null 
bin-links = true 
browser = null 
ca = null 
cache = "/Users/user/.npm" 
cache-max = null 
cache-min = 0 
cafile = null 
call = "" 
cert = null 
ci-name = null 
cidr = null 
color = true 
commit-hooks = true 
depth = null 
description = true 
dev = false 
diff = [] 
diff-dst-prefix = "b/" 
diff-ignore-all-space = false 
diff-name-only = false 
diff-no-prefix = false 
diff-src-prefix = "a/" 
diff-text = false 
diff-unified = 3 
dry-run = false 
editor = "vi" 
engine-strict = false 
fetch-retries = 2 
fetch-retry-factor = 10 
fetch-retry-maxtimeout = 60000 
fetch-retry-mintimeout = 10000 
fetch-timeout = 300000 
force = false 
foreground-scripts = false 
format-package-lock = true 
fund = true 
git = "git" 
git-tag-version = true 
global = false 
global-style = false 
globalconfig = "/Users/user/.nvm/versions/node/v17.0.1/etc/npmrc" 
heading = "npm" 
https-proxy = null 
if-present = false 
ignore-scripts = false 
include = [] 
include-staged = false 
include-workspace-root = false 
init-author-email = "" 
init-author-name = "" 
init-author-url = "" 
init-license = "ISC" 
init-module = "/Users/user/.npm-init.js" 
init-version = "1.0.0" 
init.author.email = "" 
init.author.name = "" 
init.author.url = "" 
init.license = "ISC" 
init.module = "/Users/user/.npm-init.js" 
init.version = "1.0.0" 
json = false 
key = null 
legacy-bundling = false 
legacy-peer-deps = false 
link = false 
local-address = null 
location = "user" 
lockfile-version = null 
loglevel = "notice" 
logs-max = 10 
; long = false ; overridden by cli
maxsockets = 15 
message = "%s" 
metrics-registry = "https://registry.npmjs.org/" 
node-options = null 
node-version = "v17.0.1" 
noproxy = [""] 
npm-version = "8.1.4" 
offline = false 
omit = [] 
only = null 
optional = null 
otp = null 
pack-destination = "." 
package = [] 
package-lock = true 
package-lock-only = false 
parseable = false 
prefer-offline = false 
prefer-online = false 
prefix = "/Users/user/.nvm/versions/node/v17.0.1" 
preid = "" 
production = null 
progress = true 
proxy = null 
read-only = false 
rebuild-bundle = true 
registry = "https://registry.npmjs.org/" 
save = true 
save-bundle = false 
save-dev = false 
save-exact = false 
save-optional = false 
save-peer = false 
save-prefix = "^" 
save-prod = false 
scope = "" 
script-shell = null 
searchexclude = "" 
searchlimit = 20 
searchopts = "" 
searchstaleness = 900 
shell = "/bin/zsh" 
shrinkwrap = true 
sign-git-commit = false 
sign-git-tag = false 
sso-poll-frequency = 500 
sso-type = "oauth" 
strict-peer-deps = false 
strict-ssl = true 
tag = "latest" 
tag-version-prefix = "v" 
timing = false 
tmp = "/var/folders/gb/40nmdn5d45b_98f3p6ppwwmr0000gn/T" 
umask = 0 
unicode = true 
update-notifier = true 
usage = false 
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}" 
userconfig = **"/Users/user/.npmrc"** 
version = false 
versions = false 
viewer = "man" 
which = null 
workspace = [] 
workspaces = null 
yes = null 

; "cli" config from command line options

long = true

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions