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.

npm run eject fails when removing node_modules

See original GitHub issue

Description

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.1
  • npm -v: 6.0.0
  • yarn --version: 1.6.0
  • watchman version: 4.9.1

Also specify:

  1. Operating system: Windows 7 64-bit
  2. 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:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

6reactions
Luismi74commented, Aug 1, 2018

my solution: npm install -g react-native-scripts then run react-native-scripts eject . this will do the same as npm run eject. hope it works!

1reaction
geisterfurz007commented, Jul 21, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run eject fails when removing node_modules #668 - GitHub
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...
Read more >
undo 'npm run eject' in react - Stack Overflow
I was trying to test the performance of my React app(created with create-react-app) with react CDN script and i did 'npm run eject'...
Read more >
Troubleshooting - Create React App
We recommend deleting node_modules in your project and running npm install (or yarn if you use it) first. If it doesn't help, ...
Read more >
react-hot-loader - npm
Run npm run eject; Install React Hot Loader ( npm install --save-dev react-hot-loader ); In config/webpack.config.dev.js ...
Read more >
How To Set Up a React Project with Create React App
npm run eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you...
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