I have the following project structure:
workspace_test
│ package.json
│
└───dist
└───libs
└───pkg
package.json
The workspace_test/project.json
contains npm workspaces:
{
"name": "project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"workspaces": [
"dist/libs/*"
]
}
The dist/libs/pkg/package.json
, is the output of a compilation, and does not contain anything significant (I just initialized it with npm init -y
for testing purposes).
If I run npm config list
in the root of the project, I successfully get output from it. But if I run it inside dist/libs/pkg
, I get the following erroneous output:
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.
npm ERR! A complete log of this run can be found in: C:\Users\Elias\AppData\Local\npm-cache\_logs\2023-07-05T07_00_50_459Z-debug-0.log
The debug log doesn't seem to provide any more relevant details.
How would I go about fixing this?
Reproduction:
Run the following commands to reproduce the issue:
mkdir workspace_test
cd workspace_test
mkdir dist/libs/pkg
cd dist/libs/pkg
npm init -y
Add "workspaces": ["dist/libs/*"]
to workspace_test/project.json
. Assure the shell in still in dist/libs/pkg
, and then the problem should occur by running:
npm config list
Versions:
Should be the latest stable, as I've tried to upgrade them to fix the problem at hand.
node : v18.16.1
npm : 9.7.2
Additional background information (Azure Pipelines):
This whole ordeal is happening in an azure publish pipeline. So it, being the azure provided Npm@1 task, tries to run npm config list
in a package artifact. I've found that running npm config list --no-workspaces
works, but I don't think I have control over the arguments.
The task looks like this:
- ${{ each package in parameters.packages }}:
- task: Npm@1
displayName: 'Publish ${{ package.packageName }} Package'
continueOnError: true
inputs:
command: publish
workingDir: ${{ package.pathToDist }}
publishRegistry: useFeed
publishFeed: ${{ parameters.npmFeedId }}