Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project can not work after upgrade react-scripts form 2.0.0-next.a671462c to 2.0.0 #5116

Closed
xiaosongxiaosong opened this issue Sep 27, 2018 · 5 comments · Fixed by #5142
Closed

Comments

@xiaosongxiaosong
Copy link

Is this a bug report?

yes

Did you try recovering your dependencies?

yes

Which terms did you search for in User Guide?

"Updating to New Releases", "Migrating from 2.0.0-next.xyz"

Environment

(paste the output of the command here)
faild to run create-react-app --info
Environment:
OS: Windows 10
Node: 8.11.4
Yarn: 1.5.4
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: ^16.5.2 => 16.5.2
react-dom: ^16.5.2 => 16.5.2
react-scripts: 2.0.0-next.a671462c => 2.0.0

Steps to Reproduce

(Write your steps here:)

  1. init project with react-scripts@2.0.0-next.a671462c
$ create-react-app app --scripts-version 2.0.0-next.a671462c
  1. add dva and modify src/index.js
$ cd app
$ yarn add dva
// src/index.js
import React from 'react';
import dva from 'dva';
import createHistory from 'history/createHashHistory';

// 1. Initialize
const app = dva({
  history: createHistory(),
});

// 2. Plugins
// app.use({});

// 3. Register global model
// app.model(require('../models/index').default);

// 4. Router
app.router(() => <div>Test</div>);

// 5. Start
app.start('#root');
  1. The project can be successfully started
$ yarn start
yarn run v1.5.1
$ react-scripts start
Starting the development server...
Compiled successfully!

You can now view app in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://192.168.30.22:3000/

Note that the development build is not optimized.
To create a production build, use yarn build.
  1. update react-scripts to 2.0.0, project can not work any more.
$ yarn add --exact react-scripts@2.0.0
$ yarn start
yarn run v1.5.1
$ react-scripts start
Starting the development server...
Failed to compile.

./node_modules/dva-core/lib/index.js
Module not found: Can't resolve '@babel/runtime/core-js/get-iterator' in 'D:\git
hub\app\node_modules\dva-core\lib'
Compiling...
Failed to compile.

./node_modules/dva-core/lib/index.js
Module not found: Can't resolve '@babel/runtime/core-js/get-iterator' in 'D:\git
hub\app\node_modules\dva-core\lib'

Expected Behavior

(Write what you thought would happen.)
image

Actual Behavior

(Write what happened. Please add screenshots!)
image

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)
https://github.com/goblin-laboratory/cra/tree/demo

@xiaosongxiaosong xiaosongxiaosong changed the title project can not work after update react-scripts form 2.0.0-next.a671462c to 2.0.0 project can not work after upgrade react-scripts form 2.0.0-next.a671462c to 2.0.0 Sep 27, 2018
@Timer Timer added this to the 2.0.0 milestone Sep 27, 2018
@gaearon
Copy link
Contributor

gaearon commented Sep 27, 2018

Similar issue: #5103 (comment)

@Timer
Copy link
Contributor

Timer commented Sep 27, 2018

Here's my findings thus far:

Since there are two versions of @babel/runtime, one gets hoisted and the other sits next to react-scripts:

=> Found "@babel/runtime@7.0.0-beta.46"
info Has been hoisted to "@babel/runtime"
info Reasons this module exists
   - Hoisted from "dva#@babel#runtime"
   - Hoisted from "dva#dva-core#@babel#runtime"
info Disk size without dependencies: "1.47MB"
info Disk size with unique dependencies: "9.05MB"
info Disk size with transitive dependencies: "9.05MB"
info Number of shared dependencies: 2
=> Found "react-scripts#@babel/runtime@7.0.0"
info This module exists because "react-scripts" depends on it.
info Disk size without dependencies: "516KB"
info Disk size with unique dependencies: "556KB"
info Disk size with transitive dependencies: "556KB"
info Number of shared dependencies: 1
✨  Done in 1.29s.

(note: dva's is at root, react-scripts's is next to it)

webpack is set to look at node_modules, which I assume means it looks at react-scripts's node_modules instead of starting at the dva level.

resolve: {
// This allows you to set a fallback for where Webpack should look for modules.
// We placed these paths second because we want `node_modules` to "win"
// if there are any conflicts. This matches Node resolution mechanism.
// https://github.com/facebook/create-react-app/issues/253
modules: ['node_modules'].concat(
// It is guaranteed to exist because we tweak it in `env.js`
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
),

x-ref: webpack/webpack#6505 (comment)

I make this assumption because the module missing is with react-scripts's version, not dva's version:

joes-mbp:test-next joe$ ls node_modules/@babel/runtime/
README.md     core-js/      core-js.js    helpers/      package.json  regenerator/
joes-mbp:test-next joe$ ls node_modules/react-scripts/node_modules/@babel/runtime/
LICENSE       README.md     helpers/      package.json  regenerator/
joes-mbp:test-next joe$

So, it appears our module resolution is searching in the wrong place, not starting at the level of the project it's currently resolved to.

@Timer
Copy link
Contributor

Timer commented Sep 28, 2018

react-scripts@2.0.1 is out. Please upgrade your dependencies and see if this is fixed.

@henkvhest
Copy link

My issue in #5103 (comment) is now solved with 2.0.1

@xiaosongxiaosong
Copy link
Author

It has been fixed by upgrade react-scripts to 2.0.1.

@lock lock bot locked and limited conversation to collaborators Jan 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants