create-react-app: Cannot find module react-scripts
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
npm ls react-scripts
: D:\git – (empty)node -v
: v7.4.0npm -v
: 4.1.1- Operating system: Windows 10 Enterprise 64-bit build 14393.576
- Browser and version: Firefox 50.1.0
- create-react-app: 1.0.2
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- Use yarnpkg alias to run Yarn There’s a common tool included in Hadoop that also has a `yarn` command, which created issues for users who had Hadoop installed: * #1257 * #1363 Yarn also installs the... — committed to fson/create-react-app by fson 7 years ago
- Use yarnpkg alias to run Yarn (#1365) There’s a common tool included in Hadoop that also has a `yarn` command, which created issues for users who had Hadoop installed: * #1257 * #1363 Yarn also... — committed to facebook/create-react-app by fson 7 years ago
- Use yarnpkg alias to run Yarn (#1365) There’s a common tool included in Hadoop that also has a `yarn` command, which created issues for users who had Hadoop installed: * #1257 * #1363 Yarn also... — committed to facebook/create-react-app by fson 7 years ago
- Use yarnpkg alias to run Yarn (#1365) There’s a common tool included in Hadoop that also has a `yarn` command, which created issues for users who had Hadoop installed: * #1257 * #1363 Yarn also... — committed to alexdriaguine/create-react-app by fson 7 years ago
- Use yarnpkg alias to run Yarn (#1365) There’s a common tool included in Hadoop that also has a `yarn` command, which created issues for users who had Hadoop installed: * #1257 * #1363 Yarn also... — committed to bondz/create-react-app by fson 7 years ago
- Use yarnpkg alias to run Yarn (#1365) There’s a common tool included in Hadoop that also has a `yarn` command, which created issues for users who had Hadoop installed: * #1257 * #1363 Yarn also... — committed to CodingZeal/create-react-app by fson 7 years ago
- Merge upstream changes from create-react-app 0.9.x (#84) * Heroku Deployment: Adds a note on how to resolve "File/Module Not Found Errors" (#1260) * Adds note on how to resolve file or directory ... — committed to trunkclub/tcweb-build by iamlacroix 7 years ago
- responding to some instructions for create react [source1](https://github.com/facebook/create-react-app/issues/1363) [source2](https://github.com/facebook/create-react-app/issues/2825) [source3](https... — committed to md-web-client/cliff-effects by MichaelDimmitt 6 years ago
- responding to some instructions for create react [source1](https://github.com/facebook/create-react-app/issues/1363) [source2](https://github.com/facebook/create-react-app/issues/2825) [source3](https... — committed to md-web-client/cliff-effects by MichaelDimmitt 6 years ago
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
:Then run
npm install
.Sorry for the trouble.
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 useyarnpkg
instead as described here?cc @fson
Run
npm install
inD:\git\r\
. It seems that npm failed for some reason.This should be fixed now. Please update the global command:
This will fix the issue in newly created projects.
what i did was edit my package.json file:
I can make a PR with the change to
yarnpkg
in a moment.