question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module react-scripts

See original GitHub issue

Description

Fail to run create-react-app.cmd.

Expected behavior

create-react-app.cmd should create a react project without errors.

Actual behavior

PS D:\git> create-react-app.cmd r Creating a new React app in D:\git\r.

Installing packages. This might take a couple minutes. Installing react-scripts…

Error: Could not find or load main class add module.js:472 throw err; ^

Error: Cannot find module ‘D:\git\r\node_modules\react-scripts\package.json’ at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at checkNodeVersion (C:\Users\myh\AppData\Roaming\npm\node_modules\create-react-app\index.js:225:21) at C:\Users\myh\AppData\Roaming\npm\node_modules\create-react-app\index.js:179:5 at ChildProcess.<anonymous> (C:\Users\myh\AppData\Roaming\npm\node_modules\create-react-app\index.js:165:5) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at ChildProcess.cp.emit (C:\Users\myh\AppData\Roaming\npm\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:40:29)

Environment

  1. npm ls react-scripts: D:\git – (empty)
  2. node -v: v7.4.0
  3. npm -v: 4.1.1
  4. Operating system: Windows 10 Enterprise 64-bit build 14393.576
  5. Browser and version: Firefox 50.1.0
  6. create-react-app: 1.0.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
gaearoncommented, Jan 9, 2017

I see, that’s frustrating. We need to add better error handling for npm failures. In the meantime please copy and paste this into your package.json:

{
  "name": "r",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-scripts": "0.8.4"
  },
  "dependencies": {
    "react": "^15.4.2",
    "react-dom": "^15.4.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

Then run npm install.

Sorry for the trouble.

5reactions
gaearoncommented, Jan 9, 2017

OK, I think I understand the issue now.

You have something called yarn on your system which is a Java program. Create React App thinks it is Yarn package manager and attempts to use it instead of npm.

This is the same issue as https://github.com/facebookincubator/create-react-app/issues/1257. As a temporary workaround you can remove yarn from your path. I understand it’s inconvenient. Would you like to submit a PR for detection code to use yarnpkg instead as described here?

cc @fson

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module '\react-scripts\bin\react-scripts.js'
It's happening most likely because of an & in your folder name which is getting used as the path of your project. So...
Read more >
react-scripts - npm
Configuration and scripts for Create React App.. ... Start using react-scripts in your project by running `npm i react-scripts`.
Read more >
Cannot find module 'react' Error in TypeScript | bobbyhadz
To solve the "Cannot find module react or its corresponding type declarations" error, install the module and its type definitions by running the...
Read more >
Everything you need to know about react-scripts
Fortunately, today we have Create React App, a handy module that comes with an outstanding configuration, and a scripts command called ...
Read more >
Solved: Cannot find module react : npm install - YouTube
Your browser can't play this video. ... Solved: Cannot find module react : npm install ... 58K views 3 years ago React.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found