Skip to content

[BUG] 10.5.2 regresses running scripts from workspaces in certain Dockerfiles with error No workspaces found #7413

@jAg-upfort

Description

@jAg-upfort

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

npm as of version 10.5.2 no longer lets you run scripts in a workspace package.json if your project is located at /. I've confirmed it worked in 10.5.1.
image

the specific error is

 > [6/7] RUN npm run -w packages/workspace build:                                                                                                                                                                   
2.156 npm ERR! No workspaces found:
2.157 npm ERR!   --workspace=packages/workspace
2.161 
2.161 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-04-24T18_23_18_824Z-debug-0.log
------
Dockerfile.txt:14
--------------------
  12 |     RUN npm install -g npm@$NPM_VERSION
  13 |     
  14 | >>> RUN npm run -w packages/workspace build
  15 |     
  16 |     ENTRYPOINT ["bash"]
--------------------
ERROR: failed to solve: process "/bin/sh -c npm run -w packages/workspace build" did not complete successfully: exit code: 1

I've included a zipped project, the 4 individual files and a screenshot of the project with all the files in their entirety visible. The top level package.json has scripts to build the dockerfile in ways that show the bug and that it's a regression.

image

npm-bug-example.zip

package.json
Dockerfile.txt
package-lock.json
package.json

Expected Behavior

The Dockerfile should build, and not fail due to being unable to find the workspace. This works successfully in 10.5.1, but does not work in 10.5.2

Steps To Reproduce

Both validations assume the project has been unzipped from the uploaded archive or recreated with the raw files in the right places, that docker is installed, and that the testing environment has an internet connection for downloading the base docker images.

I have personally only run this on an Ubuntu system, so Windows or mac users might have other setup requirements.

To validate the issue:

  1. run npm run npm-bad

To validate that things work in 10.5.1:

  1. run npm run npm-good

Environment

  • npm: 10.5.2
  • Node.js: node 18 or 20 will hit this issue. I didn't test any other releases
  • OS Name: whatever the node:iron and node:hydrogen dockerfiles use, but i've also recreated the issue with ubuntu:jammy and postgres:15-bullseye for shiggles as part of debugging the issue in my actual environment
  • System Model Name: ?
  • npm config:
#10 [6/8] RUN npm config ls
#10 2.477 ; node bin location = /usr/local/bin/node
#10 2.477 ; node version = v20.12.2
#10 2.477 ; npm local prefix = /
#10 2.477 ; npm version = 10.5.2
#10 2.477 ; cwd = /
#10 2.477 ; HOME = /root
#10 2.477 ; Run `npm config ls -l` to show all defaults.
#10 DONE 2.6s

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions