npm run eject fails when removing node_modules
See original GitHub issueDescription
When running npm run eject
everything goes well up to the point where the code removes the node_modules folder where it fails on a random module.
Expected Behavior
The script runs without issues and displays a success message (or informs me in any way that everything went well.
Observed Behavior
Randomly while removing the process fails with the error message that a folder could not be removed because it is not empty. After that there is a line telling me that a directory was not found and then there is the usual npm error block:
Error running eject: Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\Username\ReactNative\ProjectName\node_modules\lottie-react-native\src\android\build\tmp\expandedArchives\classes.jar_5gdp4bb5izj6gs3qq6f6ejit7\com\facebook\react'
System cannot find the given directory (translated from German; might be inaccurate)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ProjectName@0.1.0 eject: `react-native-scripts eject`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ProjectName@0.1.0 eject 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\Username\AppData\Roaming\npm-cache\_logs\2018-05-26T22_22_42_547Z-debug.log
I tried to get around this by using Ctrl+C to pause execution of the script, remove the folders in node_modules by hand and then continuing the process however that seemed to crash the script, no further output was printed and I was able to put in a new command (without yarn install for example was run).
Environment
Please run these commands in the project folder and fill in their results:
npm ls react-native-scripts
:
ProjectName@0.1.0 C:\Users\Username\ReactNative\ProjectName
`-- (empty)
(1.14.0 is installed)
npm ls react-native
:
ProjectName@0.1.0 C:\Users\Username\ReactNative\ProjectName
`-- UNMET DEPENDENCY react-native@0.51.1
npm ERR! missing: react-native@0.51.1, required by ProjectName@0.1.0
npm ERR! extraneous: react-native@0.51.1 C:\Users\Username\ReactNative\ProjectName\node_modules\react-native
(0.55.4 is installed)
npm ls expo
:
ProjectName@0.1.0 C:\Users\Username\ReactNative\ProjectName
`-- UNMET DEPENDENCY expo@27.0.2
npm ERR! missing: expo@27.0.2, required by ProjectName@0.1.0
(27.0.1 is installed)
node -v
: v8.9.1npm -v
: 6.0.0yarn --version
: 1.6.0watchman version
: 4.9.1
Also specify:
- Operating system: Windows 7 64-bit
- Phone/emulator/simulator & version: iPhone 5S, Galaxy S5
Reproducible Demo
Create a new project, change into the directory and eject
create-react-native-app TestingNodeModulesRemoval && cd TestingNodeModuleRemoval && npm run eject
However the issue can already be seen without ejecting by just trying to remove the node_modules folder with the command rmdir /S /Q node_modules
. This is also described in this stackoverflow post and appears to be a windows issue. It would be great though if some kind of workaround could be implemented so this does not randomly happen.
Running the command from an administrator prompt did not solve the issue.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
my solution:
npm install -g react-native-scripts
then runreact-native-scripts eject
. this will do the same as npm run eject. hope it works!Strange. I tried the same thing but it wouldn’t work either. Anyway; using git bash instead of the windows command-line appears to get rid of that issue.