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

npm config fails in workspaces #6099

Open
2 tasks done
jeffrson opened this issue Jan 27, 2023 · 11 comments
Open
2 tasks done

npm config fails in workspaces #6099

jeffrson opened this issue Jan 27, 2023 · 11 comments
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release Release 10.x

Comments

@jeffrson
Copy link

jeffrson commented Jan 27, 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

Since npm@9.3.0 calling
npm config list or
npm config get registry
inside a workspace of a worktree results in an error:

❯ npm config list
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

Here's part of the log:

28 timing npm:load:logFile Completed in 12ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 0ms
31 timing npm:load Completed in 46ms
32 timing command:config Completed in 1ms
33 verbose stack Error: This command does not support workspaces.
33 verbose stack     at Config.cmdExec (...\node_modules\npm\lib\base-command.js:123:29)
33 verbose stack     at Npm.exec (...\node_modules\npm\lib\npm.js:154:20)
33 verbose stack     at async module.exports (...\node_modules\npm\lib\cli.js:134:5)

It used to work in 9.2.0.

Expected Behavior

Well, show (and use!) all configs.

Steps To Reproduce

Build a worktree with packages. .npmrc in root. In a package call npm config list.

Environment

  • npm: 9.4.0
  • Node.js: 18.13.0
  • OS Name: Windows 10
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here
@jeffrson jeffrson added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Jan 27, 2023
@anilkeshav27
Copy link

npm config get registry also causes the same error , in the node:lts-buster docker image with npm version 9.3.1

@niteshagrawalgmail
Copy link

+1 . We are using node:lts-buster for our builds and are facing same issue.

@nlf nlf added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Feb 16, 2023
@ferferga
Copy link

This also breaks all the workflows that use actions/setup-node where workspaces are involved and cache is enabled, like this one (source)

@john-landgrave
Copy link

Just ran into this on a fresh install on a new machine. npm config set <...> fails with the following:

npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/johnl/.npm/_logs/2023-03-20T21_34_37_668Z-debug-0.log

It looks like a workaround is to go down to 0.9.2? Considering that npm workspaces is what our app uses as it's "monorepo framework" I don't suppose I have a whole lot of choice there. Is this intentional, or this is a bug of some sort?

FWIW, I did also try cding up into the particular package and running the commands directly from there (no -w involved in the command anywhere) and it still failed with the same error I presume because it can tell that it is still in a workspace.

ferferga pushed a commit to aweebs/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: Fernando Fernández <ferferga@hotmail.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.
ferferga pushed a commit to aweebs/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: Fernando Fernández <ferferga@hotmail.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the Gitrhub Actions workflows using the official VSCode GitHub extension
ferferga pushed a commit to aweebs/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: ferferga <ferferga@hotmail.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the Gitrhub Actions workflows using the official VSCode GitHub extension
ferferga pushed a commit to aweebs/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the Gitrhub Actions workflows using the official VSCode GitHub extension
ferferga added a commit to aweebs/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the Gitrhub Actions workflows using the official VSCode GitHub extension
ferferga added a commit to jellyfin/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the Gitrhub Actions workflows using the official VSCode GitHub extension
ferferga added a commit to jellyfin/jellyfin-vue that referenced this issue Mar 28, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the GitHub Actions workflows using the official VSCode GitHub extension
ferferga added a commit to jellyfin/jellyfin-vue that referenced this issue Mar 30, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the GitHub Actions workflows using the official VSCode GitHub extension
ferferga added a commit to jellyfin/jellyfin-vue that referenced this issue Apr 3, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the GitHub Actions workflows using the official VSCode GitHub extension
ferferga added a commit to jellyfin/jellyfin-vue that referenced this issue Apr 3, 2023
Co-authored-by: aweebs <8809837+aweebs@users.noreply.github.com>

Due to a regression in npm 9.3.0 (upgraded by Node.JS 18 LTS at 18.14.0,
see https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#2023-02-02-version-18140-hydrogen-lts-bethgriggs-prepared-by-juanarbol),
the `npm get config` command stopped working in workspaces. This made
our actions using actions/setup-node to fail.

Issues were opened in the relevant repositories since january
and february (check npm/cli#6099 and actions/setup-node#712)
but it looks like getting this fixed upstream it's going to take a long time.
We have been waiting for a really long time
for other fixes in npm, so I don't expect this situation will be solved really soon

We need a working CI before the Vue 3 merge, so applying this commit will
solve the issue in the meantime. In the future, it might be interesting
to revert this commit.

Also format the GitHub Actions workflows using the official VSCode GitHub extension
@kongmoumou
Copy link

When will this bug be fixed?

@vritant24
Copy link

+1 we're also facing failures in our pipeline after upgrading from node 16 -> 18 due to this issue

@davidstenstroem
Copy link

I also ran into this issue today. Using Node.js v18.17.0 and NPM v10.2.5 and v9.6.7

@prodkt
Copy link

prodkt commented Dec 7, 2023

Running into this issue across multiple environments in office and remote the last 48 hours.

@darcyclarke
Copy link
Contributor

darcyclarke commented Dec 8, 2023

npm config is a bit of a special case since I'm fairly certain the npm team don't want to let users accidentally create local .npmrc files inside workspace directories (because they aren't supported/respected & could end up causing other issues for your project). Thus, failing within a workspace helps prevent that.

That said, if you really want to manage the config of your project from within a workspace, you can by passing --workspaces=false & --include-workspace-root (-ws=false & -iwr are shorthands for these options).

Minimum working reproduction:

npm init -y -iwr -w=a && cd ./a && npm config get registry -ws=false -iwr

And in the case of the original issue:

npm config list -ws=false -iwr # OR
npm config get registry -ws=false -iwr # will work...

If, for some reason, you are trying to create/manage nested .npmrc files in your workspaces, you'll have to get a bit tricky & use npm exec. Example:

npm exec -c 'npm config get registry -ws=false' -ws # OR whatever explicit workspace you want

With the above, you'll still want to include/exclude the root (ie. -iwr) if you're trying to manage both the workspace configs & the root's.

huntie added a commit to huntie/react-native that referenced this issue Feb 13, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 13, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 14, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 15, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 15, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 15, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 15, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53609308
huntie added a commit to huntie/react-native that referenced this issue Feb 15, 2024
Summary:

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53609308
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Feb 15, 2024
Summary:
Pull Request resolved: #42941

I noticed that programatically running `npm set registry <value>` would fail within the repo root dir (intended run location) (`node` version `18.18.2`).

```
npm ERR! This command does not support workspaces.
```

It turns out this is no longer supported from npm 9.x: npm/cli#6099. **Note**: The workaround discussed in this thread is incompatible/nontrivial with `npx`, so I've opted to remove this behaviour.

**Changes**

- Remove `npm set registry http://localhost:4873` call.
    - This is non-breaking due to the [explicit `--registry` arg already present in `run-e2e-ci-tests.js`](https://github.com/facebook/react-native/blob/b366b4b42e0f91eb2b1850c404fadd0f0322fc61/scripts/run-ci-e2e-tests.js#L102). The previous `.npmrc` config value is unnecessary, and probably was being ignored (will be validated for this PR in CircleCI run).
- Add comment against remaining `.npmrc` write, convert to `fs` call.
- Remove unused params on `setupVerdaccio` (moved to constants which will be exported and referenced in the next diff).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53609308

fbshipit-source-id: 77d3666b42963cd61f6d3fd0be00cdc19bbb1ec8
@jfly
Copy link

jfly commented Feb 23, 2024

you can by passing --workspace=false & --include-workspace-root (-ws=false & -iwr are shorthands for these options).

Since this tripped me up: it's --workspaces=false (plural).

edit: Just so there's a simple answer that people can actually copy paste, the following commands work for me inside of a npm workspace. Do read @darcyclarke's original post for a more nuanced answer, though.

$ npm config get --workspaces=false --include-workspace-root
$ npm config get -ws=false -iwr

jfly added a commit to jfly/simple-npm-workspace that referenced this issue Feb 29, 2024
I created this by following the instructions on
https://docs.npmjs.com/cli/v7/using-npm/workspaces.

(This is just to simplify reproducing
npm/cli#6099)
@ThePlenkov
Copy link

Seriously? Is it a problem to read the config from workspace? Why is not still fixed?

wesleyboar added a commit to TACC/tup-ui that referenced this issue May 13, 2024
Optional dependencies are installed by default.

We can not disable "install optional by default", cuz NX will fail:
nrwl/nx#20617

We can not configure NPM to omit optional deps only per workspace, cuz:
npm/cli#6099
wesleyboar added a commit to TACC/tup-ui that referenced this issue May 16, 2024
* feat: tup-700 storybook

STEPS
1. `npm add -D @nx/storybook@17.2.8`
2. `npx nx@17.2.8 g @nx/storybook:configuration core-components --uiFramework="@storybook/react-vite" --bundler="vite"`
3. "Do you want to set up Storybook interaction tests? (Y/n) ›  false"

CONCERNS
1. Generator installed `@swc-node/register` and `@swc/core`.
2. `@vitejs/plugin-react-swc` is already isntalled.
3. [Storybook 7 does not work with @vitejs/plugin-react-swc](storybookjs/storybook#22381)
4. I worry I cannot move to Storybook 8 via NX, because it requires NX v18.

* deps: tup-700 uninstall `@swc-…`

- Vite already uses `@vitejs/plugin-react-swc` (notice the SWC).
- Storybook seems to work fine without these.
- I read that in v8, Storybook will stop isntalling backup compilers.

* feat: tup-700 Button stories, working Controls

* fix: tup-700 ignore stories during build

* fix: nx serve/build/test core-components

* feat: tup-700 button story

* style: npx nx format:write

* docs(tup-ui): tup-700 README "Contributing"

* fix: tup-700 npm ci core-components workspace ★

Running npm ci at this point:
- DOES reinstall deps
- does NOT create libs/core-components/node_modules
- does NOT create libs/core-components/package-lock.json

* npx nx format:write

* docs: do not reference lib names

This causes more work when renaming a library.

* docs: do reference (other) lib names

These references are outside of this lib, so yeah, reference lib name.

* docs(README): add `make start` step

* feat: make storybook optional

* feat: make storybook optional (not peer)

* docs(README): fix serve/start command

* fix: make storybook optional (not peer)

* chore: (redundantly) include optional dependences

Optional dependencies are installed by default.

We can not disable "install optional by default", cuz NX will fail:
nrwl/nx#20617

We can not configure NPM to omit optional deps only per workspace, cuz:
npm/cli#6099

* fix: limit install overhead for core-components

For core-components, tell dev to only install for core-components.

* fix: add missing dependencies for core-components

All this change was required to run `npx nx serve core-components`.

* fix: add missing `build-storybook` npm command

* fix: a TypeScript lint error

Error occurred as red squiggly udnerline in code editor when importing a component from within a component.

* fix: do not pass size to `<Button type="link">`

* feat: load global css via typescript not html
wesleyboar added a commit to TACC/tup-ui that referenced this issue May 16, 2024
* test(@tacc/core-components): TUP-700 (WIP)

* fix: tup-700 do not commit dist

* docs(README): tup-700 add `build core-components`

* feat: tup-700 peer dependencies

* feat: tup-700 build (no tested on a client yet)

* feat: tup-700 1st attempt to split files/css build

* fix: tup-700 add main file to dist

* build: tup-700 do not build tests

* fix: tup-700 add types & fix resulting errors

1. import & use `dts`
    - Fixes build error:
      > error TS2307: Cannot find module './….module.css' or its corresponding type declarations.
      > … import styles from './….module.css';

2. `"composite": true`
    - Fixes Typescript lint error:
      > Referenced project '/…/tup-ui/libs/core-components/tsconfig.lib.json' must have setting "composite": true.

3. `"declaration": true,`
    - Seemingly caused by `"composite": true`.
    - Fixes Vite build error:
    > \> nx run core-components:build:production
    > error TS6304: Composite projects may not disable declaration emit.

* fix: tup-700 tag types in package.json

* style: tup-700 move rollup opts input glob inline

* style: npx nx format:write

* style: tup-700 peerDependencies

"So the consuming application is aware that it must have React installed to use this package."
— https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#dependencies

* feat: tup-700 add CSS as sideEffects

"To prevent the CSS files from being accidentally removed by the consumer's tree-shaking efforts…"
—https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#side-effects

* feat: tup-700 ensure build before publish

* fix: tup-700 do 2d5ab1c, 6336f2c, 233f165 correct

Move the changes from thsoe commits to be in core-components package.json, not root package.json.

- style: tup-700 peerDependencies

    "So the consuming application is aware that it must have React installed to use this package."
    — https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#dependencies

- feat: tup-700 add CSS as sideEffects

    "To prevent the CSS files from being accidentally removed by the consumer's tree-shaking efforts…"
    — https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma#side-effects

- feat: tup-700 ensure build before publish

* chore: tup-700 resolve vite.config.ts comment code

Resolve all commented code in `vite.config.ts`.

- `outDir` DELETED cuz `rollupOptions` > `output` exists
- `reportCompressedSize` RESTORED cuz why not & it was already there
- `commonjsOptions` & `transformMixedEsModules` DELETED cuz…
    - no `require` i.e. common js modules
- `lib`'s `name` and `fileName` DELETED cuz…
    - `rollupOptions` > `output` > `assetFileNames` exists
    - `rollupOptions` > `output` > `entryFileNames` exists

* fix: tup-700 scripts inaccurate

* docs: tup-700 README

* feat: tup-700 core-components deps via workspace

* fix: tup-700 core-components deps via workspace

* npx nx format:write

* fix: core-components/package-lock.json should not exist

Only 1 root package-lock.json in an Nx project such as tup-ui.

Having this may have been cause of errors when starting CMS.

* chore: rename Navbar → NavbarWrapper

* chore: rename FieldWrapperFormik → FormikFieldWrapper

* npx nx format:write

* chore: move withBuilder to core-components

* feat: move core-wrappers to core-components

Because the distinction between them is not accurate.

Both have components that import other components.

* lint: rename some index.js to index.ts

* lint: import via rel. path not lib name

* deps: add core-wrappers deps to peerDeps

* docs: do not reference lib names

This causes more work when renaming a library.

* docs: do reference (other) lib names

These references are outside of this lib, so yeah, reference lib name.

* docs(README): remove duplicate step

* feat: TUP-700 @tacc/core-components - Storybook (#435)

* feat: tup-700 storybook

STEPS
1. `npm add -D @nx/storybook@17.2.8`
2. `npx nx@17.2.8 g @nx/storybook:configuration core-components --uiFramework="@storybook/react-vite" --bundler="vite"`
3. "Do you want to set up Storybook interaction tests? (Y/n) ›  false"

CONCERNS
1. Generator installed `@swc-node/register` and `@swc/core`.
2. `@vitejs/plugin-react-swc` is already isntalled.
3. [Storybook 7 does not work with @vitejs/plugin-react-swc](storybookjs/storybook#22381)
4. I worry I cannot move to Storybook 8 via NX, because it requires NX v18.

* deps: tup-700 uninstall `@swc-…`

- Vite already uses `@vitejs/plugin-react-swc` (notice the SWC).
- Storybook seems to work fine without these.
- I read that in v8, Storybook will stop isntalling backup compilers.

* feat: tup-700 Button stories, working Controls

* fix: tup-700 ignore stories during build

* fix: nx serve/build/test core-components

* feat: tup-700 button story

* style: npx nx format:write

* docs(tup-ui): tup-700 README "Contributing"

* fix: tup-700 npm ci core-components workspace ★

Running npm ci at this point:
- DOES reinstall deps
- does NOT create libs/core-components/node_modules
- does NOT create libs/core-components/package-lock.json

* npx nx format:write

* docs: do not reference lib names

This causes more work when renaming a library.

* docs: do reference (other) lib names

These references are outside of this lib, so yeah, reference lib name.

* docs(README): add `make start` step

* feat: make storybook optional

* feat: make storybook optional (not peer)

* docs(README): fix serve/start command

* fix: make storybook optional (not peer)

* chore: (redundantly) include optional dependences

Optional dependencies are installed by default.

We can not disable "install optional by default", cuz NX will fail:
nrwl/nx#20617

We can not configure NPM to omit optional deps only per workspace, cuz:
npm/cli#6099

* fix: limit install overhead for core-components

For core-components, tell dev to only install for core-components.

* fix: add missing dependencies for core-components

All this change was required to run `npx nx serve core-components`.

* fix: add missing `build-storybook` npm command

* fix: a TypeScript lint error

Error occurred as red squiggly udnerline in code editor when importing a component from within a component.

* fix: do not pass size to `<Button type="link">`

* feat: load global css via typescript not html
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 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release Release 10.x
Projects
None yet
Development

No branches or pull requests