Npm start gives me : 'react-scripts' is not recognized as an internal or external command, operable program or batch file.' - reactjs

Here's my remote repo, I made the project with 'create-react-app':
https://github.com/mattfrancis888/project_2
Whenever I clone the project and try to launch it with npm start. It gives me:
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.'
Why is that? I tried:
doing 'npm i'
npm install react-scripts --save ('react-scripts' is not recognized as an internal or external command)
deleting and cloning the project again.
The project works in my other computer (the desktop where I made the remote repo)

This should solve the issue;
$ sudo rm -fr node_modules/ package-lock.json
$ sudo npm cache clean --force
$ sudo npm i react-scripts --unsafe-perm
$ sudo npm i --unsafe-perm
If still throws error,
Change version of your NPM
Npm package versions and your environment are conflicting. Only way to fix is installing different versions and trying to find compatible environment to run your app.

Related

'start-storybook' is not recognized as an internal or external command,

PS C:..project\src\features> npm run storybook
> sfe-template-20#0.1.0 storybook
> start-storybook -p 6006
'start-storybook' is not recognized as an internal or external command,
operable program or batch file.
Installed storybook but can't seem to make it run. I tried npm install, will not help.
npm: '8.1.0',
node: '16.13.0'
"react": "^17.0.1",
Apparently the node version had to be downgraded to 14.15.0. After that I did rm -rf node_modules and then npm install. Since I am using Windows, before changing node version, I had to install NVM for Windows, then install the right node version and change it in CMD (have to run as Administrator).

Not able to create ReactJS application

npx create-react-app myapp
'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
spawn C:\Program Files\MySQL\MySQL Server 5.7\bin ENOENT
Do you have create-react-app installed? If it is installed just run create-react-app myapp
Try yarn it's an alternative node package manager.
I had similar problems with npm
yarn create react-app app-name
Looks like there could be some fault in your node installation. But before that make sure your npm is of at least 5.2.0 or newer. To update it to the latest do npm install -g npm.
If it still doesn't work, you should remove any global installation of create-react-app and retry. At last, I'd try to reinstall Node if I were you.
Its seems link there is some error with your npm.
Try cleaning the cache by doing
npm cache clean --force
and after that run
npm cache verify
now try creating your reach app by typing
npx create-react-app myapp
Even after doing this won't work
do install latest npm again by doing
npm install npm#latest -g

iam trying to set up a react develop environment getting error in somewhere with yarn

I am trying to set up a react develop environment getting error kin somewhere with yarn.
I have installed Node.js
npm -v
6.14.4
node -v
v10.20.1
now in my public html folder i have created the site and installed node js package
yarn install works fine.
[edu2mfgitulstagi#st03 edu2mfg-clean-architecture]$ yarn install
yarn install v1.22.4
But yarn clean and yarn build shows error
[edu2mfgitulstagi#st03 server]$ yarn clean
yarn run v1.22.4
$ npm-run-all clean:*
/bin/sh: npm-run-all: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[edu2mfgitulstagi#st03 server]$ yarn build
yarn run v1.22.4
$ npm-run-all clean lint compile copy
/bin/sh: npm-run-all: command not found
please help me to solve this.Thank you in advance

Reactjs - Demo Application is not working

I am trying setup react new setup but it is give me below error
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Error: Cannot find module '#csstools/normalize.css'
can anyone suggest me to move forward
thanks in advance
I'm able to solve the problem. The problem is that package-lock.json is pointing to the older packages.
To fix, uninstall an install the package again
Uninstall package
$ sudo npm remove csstools/normalize.css
After that, we have to install again
$ npm install csstools/normalize.css
(removing sudo from the npm install command)
rm -rf node_modules
npm cache clean --force
npm install
now try again to run your scripts, it should work
https://github.com/react-toolbox/react-toolbox-example/issues/28
I solve the same problem. The problem is that package-lock.json is pointing to the older packages. Not sure which package is but needs to be updated. The gist is that, you create a fresh reactapp, use your "package.json" to recreate "package-lock.json", and move it over back to your project. Do it AFTER you update the npm and clear the cache. Unfortunately, I didn't keep the exact sequence as I was trying to solve, following steps should be pretty close to what I did.
$ sudo npm cache clear --force
$ sudo npm install -g npm
$ cd <MYREACTAPPDIR>
$ npm install react#latest --save
$ cd ..
$ npx create-react-app tempapp
$ cp <MYREACTAPPDIR>/package.json tempapp/package.json
$ cd tempapp
$ npm install
$ cp package-lock.json ../<MYREACTAPPDIR>
$ cd ../<MYREACTAPPDIR>
$ rm -fr node_modules
$ npm install
$ npm run build
This worked for me (unfortunately a really annoying solution since it gets wiped whenever node_modules gets reinstalled), when recreating with npx create-react-app did not work.
Go to react-app/node_modules/#csstools
Change the name of the normalize.css folder into something else (ex. anormalize.css)
Take the files from the folder and paste them into the #csstools folder
Delete the anormalize.css folder
Source
fixed issue by updating npm to latest version.
sudo npm install npm#latest -g
If you're getting this error, chances are that you haven't used npx to create the react app. You must have used -
create-react-app project_name
Delete the project folder and reinstall it using -
npx create-react-app project_name
It should work this time. npx is a tool for node packages, which also installs some third party packages that running create-react-app alone might not install, hence throws the error.

react-scripts: command not found

I am currently trying to use create-react-app which uses three different packages: react, react-scripts and react-dom. I have installed create-react-app and then when I change into the directory and hit npm start I get a react-scripts: command not found. I've ran into a lot of problems with this. I can see react-scripts is in my node_modules folder but I keep getting command not found when trying to run npm start. I tried to delete and re-install all of my node_modules but it didn't work. Anyone else having this issue?
✘ ✝  Node/toDoApp/my-test   master±  npm start
> my-test#0.1.0 start /Users/jzilch/Desktop/Web
Projects/Node:Express/Node/toDoApp/my-test
> react-scripts start
sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-test#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-test#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
Firstly Delete package-lock.json file in your project folder.
And then install dependencies again by npm install. That should solve this issue.
Delete the /node_modules directory and the package-lock.json file using the rm command:
rm -rf node_modules
rm -rf package-lock.json
Install react-scripts using the following command:
npm install react-scripts
Install the dependencies using the following command:
npm install
Start the local server by running the following command:
npm run start
Note: If you are a Linux user then don't forget to add the sudo command before npm.
This usually happens because of a bad npm packages installation (using npm and yarn at the same time?). It can be desperating, but if you try these steps, it should work.
1st solution:
Remove node_modules folder. At the project's root folder, run
> yarn
> yarn run start
2nd solution:
At the project's root folder, run
> yarn upgrade
> yarn
> yarn run start
Next time you want to add a dependency using create-react-app, I recommend you to use 'yarn add' instead of 'npm install'.
(Source: https://github.com/facebook/create-react-app/issues/1155)
I use this in a dockerizer enviroment.
I already install locally in node_modules using package.json.
so, I added this:
RUN npm install -g react-scripts
RUN npm install
That solved my confusing issue
One option is to install the react-scripts package globally using the -g flag. This will make the command available to node, regardless of the working directory.
This command will install react-scripts globally:
npm install -g react-scripts
As I was using yarn, I had to run yarn add react-scripts.
I had this problem for ages and I eventually found my solution by sheer chance.
Turns out, you can't have spaces in any folder names.
e.g.
~/projects/tutorial/ReactJS/JavaScript Framework: ReactJS/app-name
won't work because JavaScript Framework: ReactJS contains spaces.
In general, it's probably not great practice to be using spaces in folder/file names anyway but I hope this saves someone at least 4 hours of trial and error.
I would recommend removing the : from your folder names too! (just to be safe)
i too faced this problem once .to solve this ,delete your
node_modules
yarn.lock
manifest_lock.json
it works .
I fixed it by changing folder name in my local system, from
new/landing
to
new_landing
However, the git branch name remains like "new/landing". This was the case with my MAC system.
For me, I deleted the project and initialized another one with the npm create-react-app <Folder Name> script. Instead of create-react-app <Folder Name>.
It worked for me.

Resources