_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ โณ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.0
Node: 8.9.3
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, upgrade
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/build-angular 0.6.0
@angular-devkit/build-optimizer 0.6.0
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0
@angular/pwa 0.6.1
@ngtools/webpack 6.0.0
@schematics/angular 0.6.0
@schematics/update 0.6.0
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
We have our code in a monorepo, using yarn workspaces, organized as such:
.
โโโโ packages
โโโโ example-lib
โโโโ public
โโโโ mobile
| package.json
โโโโ site
| package.json
angular.json
package.json
Our angular.json file has a project called site, which is located in the public folder. Yarn considers all package/* and public/* directories as separate workspaces.
From the repo root, the following command fails:
ng add @angular/pwa --project site
Error:
Installing packages for tooling via yarn.
yarn add v1.6.0
error Running this command will add the dependency to the workspace root rather than workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag
(or --ignore-workspace-root-check).
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Package install failed, see above.
Our expectation is that the desired schematic be added to our workspace appropriately.
I was able to work around the issue by modifying @angular/cli/tasks/npm-install.ts (really the compile javascript, which is a pain because the file is reinstalled) to add the -W or ---ignore-workspace-root-check flags.
Ideally, the root configuration file would be interrogated to find out if workspaces are in use, and add the switch intelligently.
Also, a quick note: we have discarded karma in favor of jest in our testing setup, so when I ported our .angular-cli file to angular.json, I didn't add an architect.test property. Once I was able to workaround the described issue, the installation still failed because the configuration was provided differently than expected. A better error message than cannot read property 'options' of undefined would be an improvement.
This is a feature request to support yarn workspaces, something that would need to be designed.
@shaunlmason add this line in your .yarnrc. see https://yarnpkg.com/lang/en/docs/yarnrc/#toc-cli-arguments
--add.ignore-workspace-root-check true
Closing this, since as @clarkorz mentioned above, Yarn config should be specified in .yarnrc and not Angular CLI.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@shaunlmason add this line in your
.yarnrc. see https://yarnpkg.com/lang/en/docs/yarnrc/#toc-cli-arguments