sindresorhus / np

A better `npm publish`
MIT License
7.56k stars 299 forks source link

`ENOWORKSPACES` when publishing from workspace #715

Open karlhorky opened 1 year ago

karlhorky commented 1 year ago

Description

Publishing one of the packages from a workspace like packages/react-scripts in a create-react-app fork leads to a ENOWORKSPACES error when running the npm config get registry command:

$ np --yolo

✖ Error: Command failed with exit code 1: npm config get registry
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

npm ERR! A complete log of this run can be found in: /Users/k/.npm/_logs/2023-09-13T12_57_00_983Z-debug-0.log
    at makeError (file:///Users/k/Library/pnpm/global/5/.pnpm/execa@7.1.1/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///Users/k/Library/pnpm/global/5/.pnpm/execa@7.1.1/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getRegistryUrl (file:///Users/k/Library/pnpm/global/5/.pnpm/np@8.0.4/node_modules/np/source/npm/util.js:154:19)
    at async ui (file:///Users/k/Library/pnpm/global/5/.pnpm/np@8.0.4/node_modules/np/source/ui.js:129:22)
    at async file:///Users/k/Library/pnpm/global/5/.pnpm/np@8.0.4/node_modules/np/source/cli-implementation.js:137:18

This is a regression since a few months - in April / May 2023 we were able to publish these packages without problems.

Steps to reproduce

  1. np --yolo or np in a package inside of a workspace

Expected behavior

np works in a package inside of a workspace without errors

Environment

np - 8.0.4 Node.js - 18.17.1 npm - 9.6.7 Git - 2.39.2 OS - macOS Ventura 13.5.2

karlhorky commented 1 year ago

Workaround (complicated)

  1. Move workspace package outside of the monorepo
  2. Create new GitHub repo
  3. git init
  4. git remote add origin <repo remote URL>
  5. git push --set-upstream origin main
  6. np