简体   繁体   中英

Migrate CRA project to existing Nx workspace

I have the Nx workspace with React and Express apps created via the official React tutorial from Nx docs. Also, I have an independent CRA project that has just one commit after using npx create-react-app command. I want to add my CRA project to Nx workspace preserving git histories. How can I do that?

I had read docs pages about preserving git histories and manual migration and then tried to migrate the project this way:

  1. Migrated CRA project to a new Nx workspace automatically used npx cra-to-nx command as the docs said.
  2. Added remote repository with initial Nx workspace .
  3. Merged the branch that contained the new Nx workspace with the main branch from the initial Nx workspace .
  4. To solve all the conflicts I accepted incoming changes (didn't change the configs of the initial Nx workspace ).

The migration was successful but then I tried to serve or build migrated CRA app and got this error: 构建错误

Where did I go wrong? Maybe I deleted some important configuration when was solving the conflicts?

This issue isn't really connected with migration from CRA to Nx. The problem was in the BUILD_PATH env that was in the yarn build script. I don't know why the BUILD_PATH isn't working this way, but when I write it in the .local.env file and not in the script, everything is fine.

The weird symbols rendered instead of the error message was the error message in russian. They are rendered correctly if I launch the yarn build script from the CRA project, not from the Nx workspace.

The migration approach that I tried to use should work, but you really don't need it. The approach from the Doing the migration manually section of CRA-to-Nx docs' page is fast and easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM