Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #7288
Closed
Open
Issue created Jun 28, 2019 by Administrator@rootContributor

Ejection fails if package.json omits optionalDependencies key

Created by: bmuenzenmeyer

Desribe the bug

Ejecting an app that does not have an optionalDependencies key within its package.json causes a failure.

This seems similar to https://github.com/facebook/create-react-app/issues/2655 and https://github.com/facebook/create-react-app/pull/2657.

Workaround: preserve the optionalDependencies key in the package.json of the app or template (in my case, we have a custom react-scripts)

I have a fix, which I will PR against this shortly.

Environment

$ npx create-react-app --info

Environment Info:

System: OS: Windows 10 CPU: (8) x64 Intel(R) Xeon(R) CPU E3-1505M v5 @ 2.80GHz Binaries: Node: 10.15.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.9.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Not Found Internet Explorer: 11.0.14393.2007 npmPackages: react: ^16.8.6 => 16.8.6 react-dom: ^16.8.6 => 16.8.6 npmGlobalPackages:


Steps to reproduce

  1. npx create-react-app test-app --scripts-version @bmuenzenmeyer/react-scripts (though I suppose you could generate the standard template and remove the optionalDependencies key just the same)
  2. cd test-app
  3. npm run eject

Expected behavior

Ejection should succeed

Actual behavior

$ npm run eject

> test-app@0.1.0 eject C:\src\tmp\test-app
> react-scripts eject

NOTE: Create React App 2+ supports TypeScript, Sass, CSS Modules and more without ejecting: https://reactjs.org/blog/2018/10/01/create-react-app-v2.html

? Are you sure you want to eject? This action is permanent. Yes
Ejecting...

Copying files into C:\src\tmp\test-app
  Adding \config\env.js to the project
  Adding \config\modules.js to the project
  Adding \config\paths.js to the project
  Adding \config\pnpTs.js to the project
  Adding \config\webpack.config.js to the project
  Adding \config\webpackDevServer.config.js to the project
  Adding \config\jest\cssTransform.js to the project
  Adding \config\jest\fileTransform.js to the project
  Adding \scripts\build.js to the project
  Adding \scripts\start.js to the project
  Adding \scripts\test.js to the project

Updating the dependencies
  Removing @bmuenzenmeyer/react-scripts from dependencies
ipts\eject.js:188:42)
    at process._tickCallback (internal/process/next_tick.js:68:7)ipts\eject.js:14
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-app@0.1.0 eject: `react-scripts eject`
npm ERR! Exit status 1 property '@babel/core' of undefined
npm ERR! ject.keys.forEach.key (C:\src\tmp\test-app\node_modules\@bmuenzenmeyer\react-scripts\scriptsnpm ERR! Failed at the test-app@0.1.0 eject script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    at inquirer.prompt.then.answer (C:\src\tmp\test-app\node_modules\@bmuenzenmeyer\react-scripts\scrnpm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<<REDACTED>>\AppData\Roaming\npm-cache\_logs\2019-06-28T17_48_09_083Z-debug.log

Reproducible demo

https://github.com/bmuenzenmeyer/test-app

  1. git clone https://github.com/bmuenzenmeyer/test-app.git
  2. cd test-app
  3. npm install
  4. npm run eject
Assignee
Assign to
Time tracking