Publish existing create-react-app using nwb - reactjs

I have an existing react application built with create-react-app version 2. I understand that I'll either have to eject it or use a tool like nwb to publish it to npm.
Could someone tell me if I can use npm on an existing project. From reading the docs it seems I have to create a new project using the command 'nwb new react-app nwb-thinking-in-react''. But if I already have a project can I just publish using nwb or would I have to copy my files into the newly created project created by the nwb new react-app nwb-thinking-in-react'command .
If you could also tell me how I would achieve the above using a project written in TypeScript, thanks
Thanks for your help.

Related

Combined Node Modules Folder for Different Dev Projects Created using create-react-app

Creating a react app using create-react-app is an easy way, however, it takes quite a time to get a dev project created (installing all dependencies). As a learner, I want to create a combined node modules folder for all my projects without using create-react-app for each project. I would like my projects structure to look like as under:-
react-apps
|-proj1
|-proj2
|-...
|-node_modules
I created basic project structure using create-react-app and subsequent projects created using npm init, but I do not know how to refer to node_modules folder in the subsequent projects.

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:
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.

How can i run reactjs locally on mac other than the npx create-react-app?

I'm just a bit annoyed by having to do npx create-react-app and wait then delete most of the files and code.
I've seen some people use npm i react react-dom, is this another way as well?
can i also use react offline ?
You can add a in your html if you don't want to use create-react-app. Then just create a file with that name. Otherwise I believe other methods still give you a boilerplate.
Even if without create-react-app, can make React applications. But it's bother than with it. create-react-app just automates downloading libraries and many many configurations. So what they do is same.
Create react app creates spa and gives entire folder structure out of the box, but you don't always need to use cra command for that, you can create spa yourself with minimal packages if you know the actual working of spa, you can use react, webpack, webpack dev server, babel.

Is it best practice to escape create react app and create our own template to get React project ready for production?

I am new to React and recently joined a team and my first assignment was to set up a react project without using create-react-app because as team lead told me custom template makes easier to put react into production. Then, the question is how about create-react-app helping us with all of the setup for us and if we want to customize the CRA we can use npm run eject. So, why should we create our own template?
On the contrary, it's pretty hard to setup a React application without a template.
You can check Creating a Toolchain from Scratch at React docs which refers to this guide.
Your own template should configure package manager, bundler and compiler, it's not so trivial. Best suggestion would be extending CRA by cloning the repo or running yarn eject and continue from there.

Where can I find systemjs.config in Ionic 2 Project?

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

Resources