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 7 workspace package script execution #1904
Comments
Link to the workspaces RFC is https://github.com/npm/rfcs/blob/latest/implemented/0026-workspaces.md |
I had a question related to the npm7 workspaces feature. If I had to install a package only to a specific workspace, what is the npm command to do that. Yarn and Lerna both support this. Assume the following workspaces.
lerna add supports lerna's filter options
|
A question. Does npm workspaces, like yarn, also require the root package to have |
While not ideal; until this issue is resolved, a workaround is to use the For example, using @fabb's steps to reproduce with the repo npm7-workspaces and replacing step 2's command with the following: npm run --prefix applications/app1 build The build succeeds: npm7-workspaces % npm -v
7.0.2
npm7-workspaces % npm run --prefix applications/app1 build
> @fabb/app1@1.0.0 build
> tsc index.ts
npm7-workspaces % echo $?
0 |
I've tested the repo fabb/npm7-workspaces. |
I think running unit tests within individual workspace(cd into it) is not possible if workspaces do not have their own node_modules(even with symbol links). 🙁 |
…as npm script execution issue See official issue: npm/cli#1904
I bring good news!Workspaces support for both assuming a file structure:
It's now possible to run a script in a given workspace. In order to run one of the scripts available in the workspace
It also supports test|start|stop|restart top level comands, so if you're using any of these you can just add
In case you want to run a script against all the configured workspaces, there's a
Lastly it's also possible to run scripts in a group of workspaces by using the path to their parent folder as the Want to learn more about it?We updated the docs, see:
|
Current Behavior:
Given a package with several workspaces,
npm install
installs all packages of the root and of the workspace packages to the rootnode_modules
. Unlike yarn, no dependencies of the workspace packages are installed into the respective workspace packagenode_modules
. That means, it is not possible to directly execute scripts when the current working directory is a subpackage.Also there does not yet seem to exist a
npm workspace
command to execute scripts from workspace packages (compare toyarn workspace
).Expected Behavior:
This blog post mentioned that the npm workspaces feature should work similar to the one of yarn:
I would expect to be able to either:
npm workspace @me/workspace-package1 my-script
to run themy-script
script in the workspace package@me/workspace-package1
(e.g. located in packages/package1)cd packages/package1 && npm run my-script
Steps To Reproduce:
I have created a workspace playground to experiment with workspace packages and compare yarn and npm7:
https://github.com/fabb/npm7-workspaces
npm install
(succeeds)cd applications/app1 && npm run build
tsc
cannot be foundNow try with yarn:
yarn
(succeeds)cd applications/app1 && yarn run build
Alternatively with yarn:
yarn
(succeeds)yarn workspace @fabb/app1 build
Environment:
Related
RFC for workspaces: https://github.com/npm/rfcs/blob/latest/accepted/0026-workspaces.md
The text was updated successfully, but these errors were encountered: