Solution
I was working on this for an hour and finally solved this issue, I found two approaches to solve this issue
Approach: 1
I Had an “&” symbol as my directory name for example C:/simple&app/App so, it’s happening most likely because of an & in your folder name which is getting used as the path of your project. So Check the whole path trail of your project and rename any folder with “&” to only text-based names.
The reason is node encounters & symbols it breaks the string into 2, at least on Windows it seems like. The part in the path after the ‘&’
is interpreted as another command as per the error and everything breaks from there.
If your problem still exists, re-install node in you system again, and check for &
symbol in your project dir, follow the below streps
- Delete
package-lock.json
file (notpackage.json
) oryarn.lock
file from your project. - Remove the node modules from your project, follow below article instructions to remove the node modules from your project
Finally, In the command window run the below command again
npm cache clean --force
npm install
Approach: 2
Go to your project’s root folder and run the following below command
It’s a pretty simple answer. I have solved my issue by using the following these commands, it works so, try this :
react-scripts build
So, I followed the below instructions, first I have deleted the package-lock.json
file, second I removed the node modules from my project, in the ‘package.json
‘ file then, I have removed babel-loader
(this was the issue in my code, so react-scripts build suggested removing this ) string name, then I cleared the cache by using the following command
npm cache clean --force
Finally, I have reinstalled node modules by executing the following command
npm i
Conclusion
If you have an ‘&’ in your project’s path you will run into this issue, it got resolved after Changing the path or try to execute command react-scripts build to find out the issue and use the following commands mentioned in there, we hope you find them helpful.