Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NPM Publish seems to not read package.json's publishConfig #6939

Closed
2 tasks done
gear4s opened this issue Oct 30, 2023 · 4 comments
Closed
2 tasks done

[BUG] NPM Publish seems to not read package.json's publishConfig #6939

gear4s opened this issue Oct 30, 2023 · 4 comments
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 10.x

Comments

@gear4s
Copy link

gear4s commented Oct 30, 2023

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

I am having an issue similar to #1937

npm publish fails to pick up publishConfig.registry from my package.json, yet it works fine if I provide it in the command line with npm publish --registry=http://my-npm.repository/

I am using Angular workspaces but no matter in which package.json I place the config, it is not followed.

Expected Behavior

I am able to publish to a private NPM repository using the NPM-provided documentation

Steps To Reproduce

package.json:

{
  "name": "my-package",
  "version": "0.0.0",
  "peerDependencies": {
    "@angular/common": "^0.0.0",
    "@angular/core": "^0.0.0"
  },
  "dependencies": {
    "tslib": "^0.0.0"
  },
  "sideEffects": false,
  "publishConfig": {
    "registry": "http://my-npm.repository/",
    "access": "restricted"
  }
}

failed attempt at publishing:

$ npm publish my-package@0.0.0 --dry-run --loglevel=silly
npm verb cli /my-user/.nvm/versions/node/v20.8.0/bin/node /my-user/.nvm/versions/node/v20.8.0/bin/npm
npm info using npm@10.1.0
npm info using node@v20.8.0
npm verb title npm publish my-package@0.0.0
npm verb argv "publish" "my-package@0.0.0" "--dry-run" "--loglevel" "silly"
npm verb logfile logs-max:10 dir:/my-user/.npm/_logs/2023-10-30T07_44_46_004Z-
npm verb logfile /my-user/.npm/_logs/2023-10-30T07_44_46_004Z-debug-0.log
npm verb publish [ 'my-package@0.0.0' ]
npm sill logfile start cleaning logs, removing 1 files
npm sill logfile done cleaning log files
npm http fetch GET 404 https://registry.npmjs.org/my-package 1536ms (cache skip)
npm http fetch GET 404 https://registry.npmjs.org/my-package 947ms (cache skip)
npm verb stack HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/my-package - Not found
npm verb stack     at /my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verb stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm verb stack     at async RegistryFetcher.packument (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:87:19)
npm verb stack     at async RegistryFetcher.manifest (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:118:23)
npm verb stack     at async Publish.getManifest (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/lib/commands/publish.js:213:18)
npm verb stack     at async Publish.exec (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/lib/commands/publish.js:67:20)
npm verb stack     at async module.exports (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/lib/cli-entry.js:61:5)
npm verb statusCode 404
npm verb pkgid my-package@0.0.0
npm verb cwd /my-user/projects/my-package
npm verb Darwin 23.0.0
npm verb node v20.8.0
npm verb npm  v10.1.0
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/my-package - Not found
npm ERR! 404 
npm ERR! 404  'my-package@0.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm verb exit 1
npm verb code 1

npm ERR! A complete log of this run can be found in: /my-user/.npm/_logs/2023-10-30T07_44_46_004Z-debug-0.log

"successful" attempt at publishing

$ npm publish my-package@0.0.0 --dry-run --loglevel=silly --registry=http://my-npm.repository/
npm verb cli /my-user/.nvm/versions/node/v20.8.0/bin/node /my-user/.nvm/versions/node/v20.8.0/bin/npm
npm info using npm@10.1.0
npm info using node@v20.8.0
npm verb title npm publish my-package@0.0.0
npm verb argv "publish" "my-package@0.0.0" "--dry-run" "--loglevel" "silly" "--registry" "http://my-npm.repository/"
npm verb logfile logs-max:10 dir:/my-user/.npm/_logs/2023-10-30T07_51_12_291Z-
npm verb logfile /my-user/.npm/_logs/2023-10-30T07_51_12_291Z-debug-0.log
npm verb publish [ 'my-package@0.0.0' ]
npm sill logfile start cleaning logs, removing 1 files
npm sill logfile done cleaning log files
npm http fetch GET 404 http://my-npm.repository/my-package 2748ms (cache skip)
npm http fetch GET 404 http://my-npm.repository/my-package 312ms (cache skip)
npm verb stack HttpErrorGeneral: 404 Not Found - GET https://my-npm.repository/my-package - not_found
npm verb stack     at /my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verb stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm verb stack     at async RegistryFetcher.packument (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:87:19)
npm verb stack     at async RegistryFetcher.manifest (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:118:23)
npm verb stack     at async Publish.getManifest (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/lib/commands/publish.js:213:18)
npm verb stack     at async Publish.exec (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/lib/commands/publish.js:67:20)
npm verb stack     at async module.exports (/my-user/.nvm/versions/node/v20.8.0/lib/node_modules/npm/lib/cli-entry.js:61:5)
npm verb statusCode 404
npm verb pkgid my-package@0.0.0
npm verb cwd /my-user/projects/my-package
npm verb Darwin 23.0.0
npm verb node v20.8.0
npm verb npm  v10.1.0
npm ERR! code E404
npm ERR! 404 Not Found - GET http://my-npm.repository/my-package - not_found
npm ERR! 404 
npm ERR! 404  'my-package@0.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm verb exit 1
npm verb code 1

npm ERR! A complete log of this run can be found in: /my-user/.npm/_logs/2023-10-30T07_51_12_291Z-debug-0.log

Environment

  • npm: 10.2.1
  • Node.js: v20.8.0
  • OS Name: macOS Sonoma 14.0
  • System Model Name: MacBook Pro 2021 M1
//my-npm.repository = (protected)

; node bin location = /my-user/.nvm/versions/node/v20.8.0/bin/node
; node version = v20.8.0
; npm local prefix = /my-user
; npm version = 10.2.1
; cwd = /my-user
; HOME = /my-user
; Run `npm config ls -l` to show all defaults.
@gear4s gear4s added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Oct 30, 2023
@wraithgar wraithgar added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Nov 7, 2023
@wraithgar wraithgar self-assigned this Nov 7, 2023
@wraithgar
Copy link
Member

This is because you are typing the package name instead of a directory

npm publish my-package@0.0.0

When npm goes to look for publishConfig it looks at the spec you gave, and of course that won't work because it is a registry spec.

Unless you are trying to publish a package that exists in one registry into another one you would not use npm publish in this way. You would simply type npm publish or in some cases npm publish /path/to/package.

@gear4s
Copy link
Author

gear4s commented Nov 14, 2023

@wraithgar thank you - where can I find the documentation to make a note of this? it is completely unclear and I would like to contribute this short note to the project :)

@wraithgar
Copy link
Member

@gear4s
Copy link
Author

gear4s commented Nov 15, 2023

thanks a bunch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 10.x
Projects
None yet
Development

No branches or pull requests

2 participants