-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
nx migrate latest
fails on yarn 2
#5672
Comments
Although my repo is not using yarn 2 workspaces, just regular yarn, I get the a similar error as above. It is just a toy project, but we will be using nx and angular in a project so encountering this problem could be a problem in the future. Eror message:
Enviorenment: Depndencies |
With Yarn 2 here, same problem different message:
nx report
|
@fatihdogmus I encountered the same error and it turned out to be the Angular CLI not supporting my installed version of Node (v16, see issue: angular/angular-cli#20796 ). Running |
@luejerry yes! that was exactly the reason! I downgraded the version to 14.17.0 and it worked. Thx a lot |
Yarn 2 ignores the engine requirements, so Angular 12 should be fine on Yarn 2 + Node 16 and won't stop the install |
It works with node v14, with v16 not, same exception on migration from 12.2.0 to 12.3.5 |
For the record, the reproduction repo still fails with node 14.17.0. |
Still having issues with this. |
For what its worth, using EDIT: I also had to unplug @nrwl/tao and modify it to get it to work - modify I also removed |
this is still an issue. I am getting the same error with the below configuration:
|
Here's a recipe that worked for me: First, MAKE SURE YOU DON'T HAVE a ".npmrc" file in your repo, otherwise, it won't work.
diff --git a/src/commands/migrate.js b/src/commands/migrate.js
index fe11e0558eeede06642d21f307ee18c2ca0d24d5..a1e4874846bc9e4a67fd18b9db5021de243bd751 100644
--- a/src/commands/migrate.js
+++ b/src/commands/migrate.js
@@ -317,7 +317,7 @@ function createFetcher() {
return function f(packageName, packageVersion) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!cache[`${packageName}-${packageVersion}`]) {
- const dir = tmp_1.dirSync().name;
+ const dir = tmp_1.dirSync({ tmpdir:process.cwd() }).name;
const npmrc = checkForNPMRC();
if (npmrc) {
// Creating a package.json is needed for .npmrc to resolve Like so: "@nrwl/tao": "patch:@nrwl/tao@13.1.3#patches/nx-tao-patch.patch", (provided the patch above is saved under "patches/nx-tao-patch.patch" in the repo) AND
NX_MIGRATE_USE_LOCAL=true yarn nx migrate latest Works for me! |
Here is how I am using Yarn v3 successfully. Start with Then run Addd Run
Then commit. I am having no issues with Yarn v3 and updating Nx 👯 Crack a beer. |
Y'all might be interested in feat(core): implement Yarn v3 |
Can confirm this issue using Yarn 1 with Node 16. Switching to Node 14 for the migration seems to work. |
One use case to contribute is if you run it with |
I think this particular issue has been fixed, since we now create package.json for any folder that receives packages temporarily as it is required to obey .npmrc. There may still be things broken w/ yarn 2 and pnp, those are tracked via #2386. I'm going to close this out in favor of that issue. I can't provide any updates as to yarn 2 / pnp support, but it is something that we are aware of. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
When running
YARN_NODE_LINKER="node-modules" yarn nx migrate latest
in a yarn 2 nx workspace, the process ends withCommand failed: yarn add @nrwl/workspace@latest
.Expected Behavior
The workspace should be migrated to the latest version of nx
Steps to Reproduce
npm install -g yarn
yarn
in the projectYARN_NODE_LINKER="node-modules" yarn nx migrate latest
Explanation for failure
After creating the temporary directory for
tao
,tao migrate latest
is run from that environment. This command creates a new temporary directory and attempts to runyarn add @nrwl/workspace@latest
which fails because nopackage.json
exists. In the repo I linked above, I added a script calledtao-yarn-add
which emulates this failure by runningyarn tao-yarn-add
. This must be run via yarn in order to emulate callingyarn add
and getting the yarn 2 engine. I've also added a script topackage.json
calledtao-yarn-add-fixed
that adds apackage.json
to the empty directory before callingyarn add
and this fixes the issue. Again, this script must be run withyarn tao-yarn-add-fixed
.Failure Logs
Environment
Node : 16.1.0
OS : darwin x64
yarn : 2.4.1
nx : Not Found
@nrwl/angular : 12.2.0
@nrwl/cli : 12.2.0
@nrwl/cypress : 12.2.0
@nrwl/devkit : 12.2.0
@nrwl/eslint-plugin-nx : 12.2.0
@nrwl/express : Not Found
@nrwl/jest : 12.2.0
@nrwl/linter : 12.2.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.2.0
@nrwl/web : Not Found
@nrwl/workspace : 12.2.0
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.1.5
The text was updated successfully, but these errors were encountered: