react-app-rewired: command not found

Created on 15 Jul 2020  Â·  16Comments  Â·  Source: timarney/react-app-rewired

I install this package in 'devDependencies',

  "devDependencies": {
    "customize-cra": "^1.0.0",
    "react-app-rewired": "^2.1.6",
    "typescript": "^3.7.5"
  }

then config everything as readme.md said,
then 'npm start',

  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "eject": "react-scripts eject"
  },

i got this error:

> react-app-rewired start

sh: react-app-rewired: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn

Most helpful comment

Was the issue ever solved? I am having this exact issue. And I answer yes to all of those questions above.

All 16 comments

Did you run npm install after adding react-app-rewired to your dev dependencies?

yes

  • Are you able to share a repository that duplicates your issue?
  • Are you using a normal project, or some form of monorepo?
  • Does the directory "<root_dir>/node_modules/react-app-rewired" exist? If not - react-app-rewired is not installed.
  • Does the file "<root_dir>/node_modules/.bin/react-app-rewired" exist? If not - something odd has happened, as this should be a link to the file "<root_dir>/node_modules/react-app-rewired/bin/index.js"

Was the issue ever solved? I am having this exact issue. And I answer yes to all of those questions above.

@smallzZz8 - The original poster didn't come back with any information, so I hadn't been able to duplicate the issue in order to debug it.

If those files are there in your installation, npm should be able to find react-app-rewired in the node_modules/.bin directory. From: https://docs.npmjs.com/cli/run-script

In addition to the shell’s pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix. For example, if there is a devDependency on tap in your package, you should write:
"scripts": {"test": "tap test/\*.js"}
instead of
"scripts": {"test": "node_modules/.bin/tap test/\*.js"}
to run your tests.

If you can share a repo that duplicates the issue, can I please request a link to the repo (assuming that was part of what you were saying 'yes' to)?

One other thing to double-check is that you haven't accidentally made a typo in your package.json file (e.g. typed react-app-rewire start instead of react-app-rewired start) - I have seen that happen before.

I'm happy to help - but I need to be able to duplicate the issue in order to debug it, so I really do need more information - ideally an example repository that has the issue that I can use to investigate it.

I'm having the same issue.
I cloned this repo https://github.com/uncodead/BrewUNO.
In the interface directory there's a react project that uses react-app-rewired.
I ran

npm install 
npm start

and I got this error:

'react-app-rewired' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-app-rewired start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2020-09-03T06_48_41_084Z-debug.log
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command npm run start" terminated with exit code: 1.

@meirkl
I have tried checking out that repository and tried running the above commands and everything worked correctly, but as my test machine is linux I am suspicious that the issue may be related to the difference in path handling between linux & windows.

The BrewUNO project mentions that you will need to use Git Bash if you are under windows in their readme documentation. Your log error messages appear to indicate that you are running with PowerShell instead. If that is true, can I suggest that you try running with the git bash shell to check that it's not simply an incompatibility with PowerShell?

@dawnmist
You are right. Thanks!
Works fine with Windows WSL

I just had the same issue on windows.
Project was using yarn. I deleted node_modules and yarn.lock.
Ran npm i - got 'react-app-rewired' is not recognized as an internal or external command
Ran npm i react-app-rewired and everything worked again.

Also had to to reinstall node-sass manually, so something properly broke.

Had this in the log.

9 verbose lifecycle [email protected]~start: CWD: C:\***
10 silly lifecycle [email protected]~start: Args: [ '/d /s /c', 'react-app-rewired start' ]
11 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error:[email protected] start: `react-app-rewired start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (**\AppData\Roaming\nvm\v12.16.1\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:311:20)
13 verbose stack     at ChildProcess.<anonymous> (C:**\AppData\Roaming\nvm\v12.16.1\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:311:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\****playground
16 verbose Windows_NT 6.3.9600
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"

I seem to have the same problem on a windows environment using wsl ubuntu.

Replacing yarn with npm as @ddennis mentioned is not really a solution as you can't just swap the packaging of a project. Anyone else found a solution using yarn?

@ddennis

Also had to to reinstall node-sass manually, so something properly broke.

Have you tried to do yarn rebuild node-sass or npm rebuild node-sass?

@PaulPCIO no, did not try to rebuild. I usually always just try to uninstall and then install again to fix issues. Will try to remember the rebuild command.

Still have this issue

@stevematdavies what system are you running?

Can re-open if this is indeed a bug for this repo

Turns out to be an issue with windows. try npm i react-app-rewired without installing it as a dev dependency

I was able to get this to work under powershell+yarn using "react-app-rewired.cmd start".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

windhost picture windhost  Â·  5Comments

001123 picture 001123  Â·  4Comments

artalar picture artalar  Â·  4Comments

brendonco picture brendonco  Â·  3Comments

cxyxc picture cxyxc  Â·  4Comments