Generating NX Monorepo Workspace (https://nx.dev/) is straight forward here the steps:
npx create-nx-workspace (to create empty workspace)
yarn add -D #nrwl/angular (to add nx's angular plugin/schematics)
nx generate worspace-schematic:application (to add Angular application to the NX Workspace)
What you will get is a NX workspace with Angular(latest version) application inside it. But what if I want to create NX workspace with Angular 8.0 application inside it. What would be the correct approach to create NX workspace with a concrete Angular version inside it?
find version of create-nx-workspace that corresponds your angular version.
usually it matcher angular version
then do (this example is for angular 10)
npx create-nx-workspace#10.4.10 name-of-new-workspace
Related
I have a NX monorepo with Stencil setup. I have my stencil web components, and I generate a React library using Stencil. I can use the library in a React app normally in the same repo.
I want now to be able to build the React library to be able to publish it to NPM to be able to import it in other projects.
I tried using Rollup with #nrwl/web:rollup to build it, but it only generates a bundle without a package.json file, is there a way to use that for publishing ? I also tried using #nrwl/web:webpack, but I can't find the right configuration. What is the right NX executor to use for that ? Webpack and gulp maybe ? How to configure it ?
For the Angualr lib, it was very simple, I just used #nrwl/angular:package. I was expecting something similar in React. Please help if you have encountered this issue, or have an idea.
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:
Migrated CRA project to a new Nx workspace automatically used npx cra-to-nx command as the docs said.
Added remote repository with initial Nx workspace.
Merged the branch that contained the new Nx workspace with the main branch from the initial Nx workspace.
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.
I've created nx workspace with nest.js application. I would like to add mongo-migrate-ts support which normally was started by "ts-node migrations/index.ts up" as script in packages.json. In my nx project, when I try to add script in global package.json, it says that "ts" extension is unrecognized.
There is a typescript rewrite of the original migrate mongo, much like mongo-migrate-ts, but this one is in the form of a nx plug-in. It will work a lot better for your needs if you are using nx. It is called nx-mongo-migrate. Give it a shot!
Want to move from nx 10 workspace to 12 without moving away from angular 10.
nx migrate latest however upgrade also upgrade angular by default.
I searched https://nx.dev/previous/angular/core-concepts/updating-nx.
Nothing specific mentioned here.
Can someone please let me know if it is possible and if yes then could you provide the steps.
Yes, you can update your nx monorepo without upgrading Angular with the next command:
nx migrate latest --to="#nrwl/angular#13.10.6"
Change 13.10.6 with the current version of that package. The side-effect is you can't use the Schematics this package provides.
Restore typescript package to the lastest version compatible with you Angular version
You can use:
nx migrate #nrwl/workspace --to="angular/whatever#10.0.0,angular/other#10.0.0"
I create an pure Ionic 2 project with the command.
ionic start myIonic --v2
The pure project work great, but when I compared the project structure with angularJS 2, I found the "systemjs.config.js" is missing.
My question is could "systemjs.config.js" file be replaceable?
If the answer is positive, what is the alternative file in Ionic2 based project ?
i have created a angularjs 2 based poject using angular2-cli using below command.
ng new PROJECT_NAME
when i create the project using angular2 cli, then also its not creating systemjs.config.js file.
link for angular2 cli new app .
And Systemjs.config.js file is creating in angular2 project only if i create quick start application, that too we are only creating manually. as given in official quick start document.
link for angular2 quick start app.
So using this 2 examples we can believe that systemjs.config.js file can be replaceable.
The angular-cli and ionic moved the build system from SystemJS to Webpack.
For angular
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#latest
Full angular-cli migrate docs: https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.14