Error: Cannot find module '\react-scripts\bin\react-scripts.js'

Viewed 27425

I have just started learning React and created a first app by using below commands npm install -g create-react-app npx create-react-app myapp after this i moved into my app folder and then used 'npm start' command to start the server but i go this error.enter image description here

Please help me to resolve this problem and starting the react server.

16 Answers

If you have an & in your project's path you will run into this issue, 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.

Confirming that as soon as it's removed, npm start works fine.

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 Run - npm start from the console. Hope it will solve your problem. Enjoy coding and changing the world.

this is happening because of one of the following reason -:

  • your project directory has & symbol in the name, this happens because when node encounters & symbols it breaks the string into 2, ( if you have worked with simple http authentication, you would know this issue )
  • delete you node_modules, package.lock.json, install both again and run start script - suitable for linux systems only,

If your problem still exists, re-install node in you system again, and check for & symbol in your project dir.

Its a pretty simple answer . I have not yet found out why it works but try this :

react-scripts build

It looks like npm install not executed while app creation. What you can look for is:

  1. Check if package.json is inside myapp.
  2. If node_modules directory is not created then move to 3.
  3. Run npm install or yarn to load the scripts and other dependencies.
  4. When done installing then try npm start or yarn start.

I edited my package.json file:

"scripts": {
    "start": "node node_modules/react-scripts/scripts/start.js",
    "build": "node node_modules/react-scripts/scripts/build.js",
    "test": "node node_modules/react-scripts/scripts/test.js",
    "eject": "node node_modules/react-scripts/scripts/eject.js"
  }

In the error message it says Toubro\react[...] while leaving out your whole foldername OneDrive - Larsen & Toubro\react

You may try installing the app again in a different folder with a less complex folder name.

I used Nikhil Kumar's answer:

$ npm build
$ npm start

I had a similar error when executing yarn start. Removing any special signs from the path (in my case an umlaut) resolved the problem.

remove special character for example "&" in your local drive directory path

Please check with the Project path conatins "&". This is the major cause of the issue. My issue got fixed after removing the C:*R&D*\REACTJS\thepage from the path.

In windows machine, I have folder with name contains capital i (which is "İ") in Turkish alphabet. This character leads to that error. While giving name to folders, avoid using characters other than English alphabet if you are a developer.

I ran into the same error since yesterday, I tried almost everything

  • Deleting node-modules and package-lock.json
  • I created a new react-app
  • I've tried even installing some stuff globally as suggested by other developers

But none of these really worked.

Finally, I've found that I had & in my project path

just deleted this symbol & in your directory name

remove special character for example "&" in your local drive directory path, I had & in directory name and finally deleted and problem solved

Related