I have never used react in a standalone project, always with Rails.
I wanted to create-react-app today and so I ran create-react-app myapp.
npm start and everything went smoothly until I wanted to add some npm packages, let's say flow-bin:
When I run npm install --save-dev flow-bin it says this:
npm WARN gentlyRm not removing /mypath/myapp/node_modules/espree/node_modules/.bin/acorn as it wasn't installed by /mypath/myapp/node_modules/espree/node_modules/acorn
npm notice created a lockfile as package-lock.json. You should commit this file.
+ flow-bin#0.47.0
added 1 package and removed 1096 packages in 15.55s
And when I try to run npm start there are also some errors.
Is this a bug? Why is npm install removing my packages?
Versions:
NPM - 5.0.3
Node - 7.10.0
create-react-app - 1.3.1
Related
I have tried these two commands and am getting the same error.
npm clean cache --force
npx create-react-app client -timeout=120000
$ npx create-react-app client -timeout=120000
npm WARN exec The following package was not found and will be installed: create-react-app
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Creating a new React app in C:\web_dev\MERN\projects\booking-app\client.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network request to https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz failed, reason: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\web_dev\MERN\projects\booking-app\tmpnodejsnpm-cache\_logs\2021-12-29T13_37_03_989Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting client/ from C:\web_dev\MERN\projects\booking-app
Done.
I have just faced the same issue when upgrading an old project. What solved, in my case was:
If you use yarn:
yarn global remove create-react-app
yarn cache clean
If you use npm:
npm remove create-react-app
npx clear-npx-cache
Also make sure there is no folder in the directory where you will created the new React project because you can get another warning similar to:
The directory . contains files that could conflict:
<the file(s) name here>/
Either try using a new directory name, or remove the files listed above.
After that, npx create-react-app . ran smoothly.
Those steps described above solved the following subsequent warnings (versions may vary).:
Global warning
You are running "create-react-app" 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
tar warning
tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
Even I was getting the same error and then saw your question I closed all the task and run this command "npx create-react-app my-app" again it got solved!
I had the same problem so I uninstalled it globally then reinstall:-
npm uninstall -g create-react-app
npm uninstall create-react-app
Then I used npx:-
npx create-react-app project-app
Tell me if this works for you
Try this:
npm install -g npm#latest
npm install node
npm install -g yarn
yarn cache clean
npx create-react-app my-app
I had the same error sometime ago,
just make sure you don't have any space between the name of your directories folders
like Desktop/react project/my-react-app ...this is wrong
try this
Desktop/reactproject/my-react-app ... correction
Trying to add TypeScript to an already created React app via: https://create-react-app.dev/docs/adding-typescript
I do everything bu get the following error when I try and start:
> npx react-scripts start
Could not find a required file.
Name: index.js
Searched in: /home/karl/dev/afry/tmr-client/src
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tmr-client#0.1.0 start: `npx react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tmr-client#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/karl/.npm/_logs/2020-11-06T18_43_02_622Z-debug.log
I renamed the index.js to index.ts as stated in the guide.
I faced the same issue today with create-react-app. The problem is the version of react-scripts as per this Git issue: Git Reference
A quick solution is to update react-scripts. I am using react-scripts version 4.0.3 with no issues.
A safe way to do it based on the documentation: Create React App Docs would be to change the version of react-scripts in the package.json file to the most recent stable version like "react-scripts": "^4.0.3". Then, run npm install from the command line.
TLDR: npm i -D react-scripts#latest
Outdated react-scripts Version
I'm not sure why index.ts isn't working for you, it seems to be supported.
The only explanation is that you're using an outdated version of react-scripts, which you can update by simply running npm i -D react-scripts#latest. More detail from Updating to New Releases:
Create React App is divided into two packages:
create-react-app is a global command-line utility that you use to
create new projects. react-scripts is a development dependency in the
generated projects (including this one). When you run npx
create-react-app my-app it automatically installs the latest version
of Create React App.
If you've previously installed create-react-app globally via npm
install -g create-react-app, please visit Getting Started to learn
about current installation steps.
Create React App creates the project with the latest version of
react-scripts so you’ll get all the new features and improvements in
newly created apps automatically.
To update an existing project to a new version of react-scripts, open
the changelog, find the version you’re currently on (check
package.json in this folder if you’re not sure), and apply the
migration instructions for the newer versions.
In most cases bumping the react-scripts version in package.json and
running npm install (or yarn install) in this folder should be enough,
but it’s good to consult the changelog for potential breaking changes.
We commit to keeping the breaking changes minimal so you can upgrade
react-scripts painlessly.
If this is the issue, you're relying on global installation of create-react-app - which is not recommended given that it won't use the latest version. See note under Quick Start:
If you've previously installed create-react-app globally via npm
install -g create-react-app, we recommend you uninstall the package
using npm uninstall -g create-react-app or yarn global remove
create-react-app to ensure that npx always uses the latest version.
I installed the latest version on Node JS with npm and cannot run create-react-app.
The following problem occurs:
Creating a new React app in C:\wamp64\www\bob.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '....tgz"}},"2.3.4":{"nam'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache_logs\2019-02-26T21_21_48_727Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\wamp64\www
Done.
Versions:
Node v10.15.1
npm 6.7.0
Can somebody help?
After running npm cache clean --force
the another error occurs:
$ create-react-app bob
Creating a new React app in C:\Users\Ivana\bob.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...,"#babel/plugin-synta'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache\_logs\2019-02-27T09_18_28_856Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\Users\Ivana
Done.
From https://create-react-app.dev/docs/getting-started#creating-an-app
npx create-react-app my-app
(npx comes with npm 5.2+ and higher)
But you used
`create-react-app my-app`
If you use npm 5.1 or earlier, you can't use npx. Instead, install create-react-app globally:
npm install -g create-react-app
Now you can run:
create-react-app my-app
I was also not able to create a new app but when I follow these step
then it works for me.
After a few searches, I found this :
If you've previously installed create-react-app globally via npm install -g
create-react-app, we recommend you uninstall the package using npm uninstall -g
create-react-app to ensure that npx always uses the latest version.
So if you installed create-react-app with
npm -g install create-react-app
just run :
npm -g uninstall create-react-app
npx create-react-app
It should do the job
I was able to solve this problem by,
running
npm cache clean --force
then
npm create-react-app my-app
I had created reactjs project first I had installed globally create react app
npm install -g create-react-app
next, I try to project creation. am using this command
create-react-app react-firebase
while installing i had faced npm ERR! 404 Not Found: react-dev-utils#^5.0.2
error:
npm ERR! code E404
npm ERR! 404 Not Found: react-dev-utils#^5.0.2
How to fix it...
i tried this yarn add -g react-dev-utils#https://registry.npmjs.org/react-dev-utils/react-dev-utils-5.0.2.tgz (remove the "/-/" from the URL) and then run create-react-app my-app and it worked.
or if using npm try:
npm install -g react-dev-utils#https://registry.npmjs.org/react-dev-utils/react-dev-utils-5.0.2.tgz
The problem is npm is not able to find react-dev-utils in the registry server.
you can try different registries as mentioned here
Can't install any packages in Node.js using "npm install"
then you can solve this installing that package
npm install react-dev-utils#^5.0.2 -g
Something has changed in the registries. Explicitly adding the package didn't work for me, but flushing the lock files to remove reference to the old registry path did:
Yarn:
Delete yarn.lock
Run yarn
NPM:
Delete package-lock.json
Run npm install
I am trying to create a new react project with create-react-app but each time it fails because of this error.......
I am using npm version 6.3.0 and node version 10.8.0
I don't know what to do............
Creating a new React app in C:\Users\Demonblade\Desktop\test.
Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Demonblade\AppData\Roaming\npm-cache\_logs\2018-08-09T15_27_48_357Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting test / from C:\Users\Demonblade\Desktop
Done.
Use npx (it comes with npm 5.2+).
From the react docs:
You’ll need to have Node >= 6 and npm >= 5.2 on your machine. To
create a project, run:
npx create-react-app my-app
cd my-app
npm start