nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.72k stars 2.27k forks source link

Updating from nx 8 to nx 9 fails #2946

Closed ThatMate closed 3 years ago

ThatMate commented 4 years ago

Based on this article: https://blog.nrwl.io/nx-cli-distributed-caching-improved-react-support-bazel-support-and-more-in-nx-9-8d55c4becdc4 I tried upgrading my local repo and It caused my React app to not load with Errors mentioned at the bottom of this issue. This is what I have done:

  1. yarn global remove @nrwl/cli followed by yarn global add @nrwl/cli

    success Installed "@nrwl/cli@9.2.3" with binaries:
          - nx
    ✨  Done in 5.60s.
  2. It seemed liked it installed version is 9.2.3, but nx --version says 8.9.0.
  3. Run yarn upgrade in your project.
  4. Run nx serve reactapp, it fails with the error.

There seem to be a document for upgrading v7 to 8 (https://nx.dev/angular/guides/nx7-to-nx8) but none for 8 to 9.

Prerequisites

Expected Behavior

yarn upgrade should update Nx for a mono-repo build using Nx 8. And this article claims that's the case: https://blog.nrwl.io/nx-cli-distributed-caching-improved-react-support-bazel-support-and-more-in-nx-9-8d55c4becdc4

I think there is a typo in the blog is says yarn update which does not work.

Current Behavior

Update fails

Failure Information (for bugs)

nx serve reactapp and nx build reactapp both fails after the upgrade.

$ nx serve reactapp
Cannot find module '/project-name/@nrwl/react/plugins/babel'
Require stack:
- /project-name/node_modules/@nrwl/web/src/builders/dev-server/dev-server.impl.js
- /project-name/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /project-name/node_modules/@angular-devkit/architect/node/index.js
- /project-name/node_modules/@nrwl/tao/src/commands/run.js
- /project-name/node_modules/@nrwl/tao/index.js
- /project-name/node_modules/@nrwl/cli/lib/init-local.js
- /project-name/node_modules/@nrwl/cli/bin/nx.js
- /Users/user-name/.config/yarn/global/node_modules/@nrwl/cli/lib/init-global.js
- /Users/user-name/.config/yarn/global/node_modules/@nrwl/cli/bin/nx.js

Steps to Reproduce

  1. Create a react project using Nx8
  2. Globally install the new version of Nx
  3. Use yarn upgrade to update dependencies
  4. nx start reactapp
epikhighs commented 4 years ago

Hi, I updated from nx 8.x to 9.x using this guide https://nx.dev/react/guides/update. Simply running yarn update won't update the NX specific "metadata" files (like workspace.json). And BTW, the globally installed version of NX does not matter as far as the repo's NX version . All the global NX does (from my experience/knowledge) is forward calls into the repo's specific version of NX. Hence, updating the global version of NX is not enough to update the repo to the next version of NX.

ThatMate commented 3 years ago

I forgot to follow up this. I cleaned my project, and followed these steps:

nx migrate @nrwl/workspace
git diff package.json
yarn
nx migrate --run-migrations=migrations.json

It worked. I had to manually updated the dependencies that were unrelated to nrwl.

github-actions[bot] commented 1 year ago

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.