Change yarn to npm when using npx install react-create-app - reactjs

I already uninstalled yarn but when I run node package execute (npx) create-react-app, yarn lock is still there but i can run it with node package manager (npm) start. How can I get I back to package-lock json or npm version when i create-react-app using npx create-react-app.
I wanna use npm for react and react-native projects.

Just delete the yarn.lock and run npm install and it will generate a package-lock.json.
package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json

Related

Hello: this problem appear when i try to deploy to vercel, i need help to solve

I try this steps to try solve.enter image description here
Clear the npm cache:
Run npm cache clean --force in your terminal.
Then, run npm install again.
Reinstall npm packages:
Delete the node_modules directory and package-lock.json file.
Run npm install again to reinstall all of the packages specified in your package.json file.
Use npm dedupe:
Run npm dedupe in your terminal.
This command will resolve and remove duplicate packages in your project's dependencies.
Upgrade or downgrade package versions:
Check the latest version of each package that is causing the conflict.
If possible, upgrade or downgrade the packages to versions that are compatible with each other and with React.

How to convert a project from npm to yarn by default

My project was initialized using npm and for a long time I had been working with npm, now I wanted to switch to yarn, since this solves some problems, the question is how to create-react-app so that by default it offers to update using yarn instead of npm
That is, yes, I can update my packages with yarn, but I would like create-react-app itself to offer an update using yarn
First, you need to have yarn installed in your computer.
Follow instruction on https://classic.yarnpkg.com/en/docs/install
Then, create-react-app will use yarn by default, as explained here:
https://create-react-app.dev/docs/getting-started/#selecting-a-package-manager
Note:
If you are trying to update an already existing app, then delete package-lock.json and node_modules, and install dependencies again with yarn:
rm -rf node_modules
rm package-lock.json
yarn install // will create a new yarn.lock file
Did you try:
yarn create <starter-kit-package> [<args>]
e.g:
$ yarn global add create-react-app
https://classic.yarnpkg.com/en/docs/cli/create/
I just delete npm from my project and leave only yarn localy and its work fine

Why React npm start return error for webpack-dev-server 3.11.1?

I have the following error with npm start in my React application:
The react-scripts package provided by Create React App requires a dependency:
"webpack-dev-server": "3.11.1"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:
C:\Users\Username\node_modules\webpack-dev-server (version: 3.11.0)
Usually I fixed this type of issue by running the following code: npm install react-scripts#latest.
But now it seems like that React is not updated yet to the latest webpack-dev-server
Now the question is how to fix that. By the way, I use npx create-react-app for my project, Thanks!
I have write following commands in react project
Open project in command prompt
npm uninstall -g webpack-dev-server
remove web-dev-server folder from node_modules(C:/Users/UserName/Node_Modules)
npm i -g webpack-dev-server#3.11.1
remove package-lock.json and write npm install
after it your react project may be start by npm start
First, remove the node_modules folder and yarn-lock or package-lock.json file.
And, then add this line in your .env file:
SKIP_PREFLIGHT_CHECK=true
Now you can do npm start or yarn start after re-installing the packages. It should work.
Explanation:
For some reasons, you have two versions of webpack-dev-server installed in your project's node_modules. By setting SKIP_PREFLIGHT_CHECK=true in .env file, we are telling npm to ignore such version issues.
Check if node_modules and package-lock.json are present in your home folder, instead of your project folder. If yes, delete those two folders and then go for npm start.

How to fix ReactJs Sass Not Compiling and error showing in vs code?

I am trying to use sass in my reactjs project and I tried
npm install node-sass
after install and import it with scss extension but not working it,
I used W3Schools Tutorial but still not working
error showing this
./src/myStyle.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/myStyle.scss)
To import Sass files, you first need to install node-sass.
Run `npm install node-sass` or `yarn add node-sass` inside your workspace.
The error is:
Run npm install node-sass or yarn add node-sass inside your workspace.
This means that the node-sass was not found inside the node_modules folder of the reactjs project.
This problem can be fixed by explicitly installing node-sass inside the project folder (using --save option along with npm install inside the project folder)
cd react-js-project-folder
npm install --save node-sass
npm install --save node-sass must be run in the root of the react-js project, I.E., at the same folder where package.json is located.

npm - install explained

I'm trying to grasp how npm install works.
Shouldn't this have installed all the dependencies in package.json ?
I wen't to the docs npm install
npm install (in package directory, no arguments):
Install the dependencies in the local node_modules folder.
1)
What i understood is when invoking npm install This package.json (/protractor/package.json) is not the place where npm will look for dependencies in the folder i am currently in.
In /node_modules there a are a bunch of packages each with it's own package.json
Why are they not getting installed ?
2)
When first cloning the app , i wen't into the root folder invoked npm install
And node models were created , and all the dependecies in ~/angular-phonecat/package.json were installed.
Why doesn't it work the same way from inside the protractor folder ?
Does it have something to do with the warning above ?
You are in an installed package. When you install protractor it automatically installs all it's dependencies because protractor is an NPM package. If you delete the "node_modules" folder in there and type npm install, it will reinstall everything. Note: this is not the purpose of npm.
NPM is used for when you have your own project and you store it on a repository, you can add all the dependencies so when a user downloads the repository they can just type npm install to get the dependencies from npm.

Resources