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

Can't contribute to React on Windows #9540

Closed
NE-SmallTown opened this issue Apr 27, 2017 · 22 comments
Closed

Can't contribute to React on Windows #9540

NE-SmallTown opened this issue Apr 27, 2017 · 22 comments

Comments

@NE-SmallTown
Copy link
Contributor

Do you want to request a feature or report a bug?
I am not sure,maybe it's just a question.

What is the current behavior?
I fork the lasted master branch of react,and execute npm run build at the root directory.But get some errors below:

D:\WebStorm_workspace\react>npm run build

> [email protected] build D:\WebStorm_workspace\react
> npm run version-check && node scripts/rollup/build.js

> [email protected] build D:\WebStorm_workspace\react
> npm run version-check && node scripts/rollup/build.js


> [email protected] version-check D:\WebStorm_workspace\react
> node ./scripts/tasks/version-check.js

 STARTING  react.development.js (umd_dev)
-- PARSE_ERROR (undefined) --
Unterminated string constant
{ file: 'D:\\WebStorm_workspace\\react\\src\\isomorphic\\React.js',
  line: 9,
  column: 7 }
undefined

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.3.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `npm run version-check && node scripts/rollup/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script 'npm run version-check && node scripts/rollup/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-build package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run version-check && node scripts/rollup/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs react-build
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls react-build
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\WebStorm_workspace\react\npm-debug.log

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/84v837e9/).

What is the expected behavior?
Build successfully.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.0.0-alpha.11 .Windows.I am not sure whether it is fine in previous versions of React,this is my first build

@gaearon
Copy link
Collaborator

gaearon commented Apr 27, 2017

Yes, the build is likely broken on Windows right now.
Probably a duplicate of #9350.

Can you look into where it breaks? We should file more issues with Rollup if it’s their bug.

@NE-SmallTown
Copy link
Contributor Author

NE-SmallTown commented Apr 27, 2017

Thanks for you reply.I try to all the solutions in the issues and the pr(involve not merged) of rollup-plugin-alias, unfortunately,it still can't work.

@NE-SmallTown
Copy link
Contributor Author

@gaearon Hi dan,is there any progress on this?

@gaearon
Copy link
Collaborator

gaearon commented May 5, 2017

No, we’re not using Windows, and would like to get community help on this.

@NE-SmallTown
Copy link
Contributor Author

get it,so I will ask for help in other place,close now,if I find a solution,I will share and reopen

@gaearon gaearon reopened this May 5, 2017
@gaearon
Copy link
Collaborator

gaearon commented May 5, 2017

I'd like to keep it open to keep track of this being broken.

@Venryx
Copy link

Venryx commented May 9, 2017

I was getting the same error as @NE-SmallTown above.

Tried fixing it, and made progress, but didn't fix it fully.

The below are obviously workarounds rather than real fixes, but anyway...

Error 1)

-- PARSE_ERROR (undefined) --
Unterminated string constant
{ file: 'C:\\Root\\Apps\\@V\\@Modules\\react\\Main\\src\\isomorphic\\React.js',
  line: 9,
  column: 7 }
undefined

Solution: Do a "replace all in files":

  • Pattern (regex): require\('.+?'\)
  • With: require("$1")

Error 2)

Error: Could not load C:\Root\Apps\@V\@Modules\react\Main\node_modules\fbjs\lib\warning (imported by C:\Root\Apps\@V\@Modules\react\Main\src\isomorphic\modern\class\ReactNoopUpdateQueue.js): ENOENT: no such file or directory, open 'C:\Root\Apps\@V\@Modules\react\Main\node_modules\fbjs\lib\warning'
    at C:\Root\Apps\@V\@Modules\react\Main\node_modules\rollup\dist\rollup.js:9461:10

Solution: Do a "replace all in files":

  • Pattern (string): require("fbjs
  • With: require("[react root]/node_modules/fbjs

Error 3)

'react' is imported by src\renderers\shared\ReactGlobalSharedState.js, but could not be resolved – treating it as an external dependency
error Command failed with exit code 1.

Solution: Make change in src\renderers\shared\ReactGlobalSharedState.js:

-var ReactInternals = require("react")
+var ReactInternals = require("[react root]/src/isomorphic/React.js")

This lets the build process get farther:

C:\Root\Apps\@V\@Modules\react\Main>npm run build

> [email protected] build C:\Root\Apps\@V\@Modules\react\Main
> npm run version-check && node scripts/rollup/build.js


> [email protected] version-check C:\Root\Apps\@V\@Modules\react\Main
> node ./scripts/tasks/version-check.js

 STARTING  react.development.js (umd_dev)
No name was provided for external module 'prop-types/checkPropTypes' in options.globals – guessing 'checkPropTypes'
No name was provided for external module 'prop-types' in options.globals – guessing 'propTypes'
No name was provided for external module 'create-react-class/factory' in options.globals – guessing 'factory'
 COMPLETE  react.development.js (umd_dev)

 STARTING  react.production.min.js (umd_prod)
No name was provided for external module 'prop-types' in options.globals – guessing 'propTypes'
No name was provided for external module 'prop-types/checkPropTypes' in options.globals – guessing 'checkPropTypes'
No name was provided for external module 'create-react-class/factory' in options.globals – guessing 'factory'
 COMPLETE  react.production.min.js (umd_prod)

 STARTING  react.development.js (node_dev)
 COMPLETE  react.development.js (node_dev)

 STARTING  react.production.min.js (node_prod)
 COMPLETE  react.production.min.js (node_prod)

 STARTING  React-dev.js (fb_dev)
 COMPLETE  React-dev.js (fb_dev)

 STARTING  React-prod.js (fb_prod)
 COMPLETE  React-prod.js (fb_prod)

 STARTING  ReactDOMStack-dev.js (fb_dev)
'ReactBaseClasses' is imported by src\isomorphic\React.js, but could not be resolved – treating it as an external dependency

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Users\\Stephen\\AppData\\Roaming\\nvm\\v6.9.1\\node.exe" "C:\\Users\\Stephen\\AppData\\Roaming\\nvm\\v6.9.1\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `npm run version-check && node scripts/rollup/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script 'npm run version-check && node scripts/rollup/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-build package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run version-check && node scripts/rollup/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs react-build
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls react-build
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Root\Apps\@V\@Modules\react\Main\npm-debug.log

However, as can be seen, I'm now getting a 'ReactBaseClasses' is imported by src\isomorphic\React.js, but could not be resolved – treating it as an external dependency error, and don't know how to fix it --
or rather, I sense that this is a replacement I'd have to make for many files, so am now giving up on the workaround-based approach.

Anyway, maybe someone else can figure out the next step. (us poor Windows people, deserted by the Linux and Mac devs... 😭)

@gaearon gaearon changed the title Get error when npm run build react Can't build React on Windows May 9, 2017
@NE-SmallTown
Copy link
Contributor Author

NE-SmallTown commented May 10, 2017

@Venryx Thanks for your attempt.

You say:

Pattern (regex): require\('.+?'\)

I don't find it,is there any typo?

@mhhegazy
Copy link

mhhegazy commented May 15, 2017

Build on windows issue has two parts:

First part [rollup-plugin-alias]:

related issue #9350
take look at rollup/rollup-plugin-alias#22 this PR solve this part.
but until it fixed on rollup-plugin-alias repository, we could use this temporary solution:

  • create rollup-plugin-alias.js in ./scripts/rollup/plugins and paste in this
  • in ./scripts/rollup/build.js replace rollup-plugin-alias with ./plugins/rollup-plugin-alias

Second part [windows path in replaced require string]:

replace modules replaceModules with rollup-plugin-replace will breaks when windows path used so we could normalize replaceModules paths (replace all \ with /) before use it in rollup-plugin-replace.

// for use with rollup repalce plugin:
// windows paths breaks the string if we dosn't replace all "\" with "/"
function normalizeReplaceModules(mapToReplace) {
  const newMap = {};
  Object.keys(mapToReplace).forEach(key => {
    newMap[key] = mapToReplace[key].replace(/\\/g, '/');
  });
  return newMap;
}

// .... and then in getPlugins()
const replaceModules = Modules.getDefaultReplaceModules(bundleType);

if (Object.keys(replaceModules).length > 0) {
  // normalizeReplaceModules only make effect on windows paths it replace "\" with "/"
  plugins.unshift(replace(normalizeReplaceModules(replaceModules))); // <----- here
}

@Venryx @NE-SmallTown @teemosauce @ccsang please confirm this solve the issue

@NE-SmallTown
Copy link
Contributor Author

NE-SmallTown commented May 16, 2017

@mhhegazy Greate work!Thanks a lot!!!Really much appreciated! 👍

@NE-SmallTown
Copy link
Contributor Author

@mhhegazy BTW,I execute the commands follow the fiber-debugger doc,but get error

Error in ./src/index.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/index.js 5:13-29

Error in ./src/index.js
Module not found: 'react-dom' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/index.js 9:16-36

Error in ./src/App.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/App.js 10:13-29

Error in ./src/App.js
Module not found: 'react-noop-renderer' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/App.js 18:25-55

Error in ./~/react-draggable/dist/react-draggable.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\node_modules\react-draggable\dist

 @ ./~/react-draggable/dist/react-draggable.js 3:27-43

Error in ./~/react-draggable/dist/react-draggable.js
Module not found: 'react-dom' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\node_modules\react-draggable\dist

 @ ./~/react-draggable/dist/react-draggable.js 3:45-65

Error in ./src/Editor.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/Editor.js 10:13-29

Error in ./src/Fibers.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/Fibers.js 12:13-29

Error in ./~/react-motion/lib/TransitionMotion.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\node_modules\react-motion\lib

 @ ./~/react-motion/lib/TransitionMotion.js 37:13-29

Error in ./~/react-motion/lib/StaggeredMotion.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\node_modules\react-motion\lib

 @ ./~/react-motion/lib/StaggeredMotion.js 33:13-29
Failed to compile.

Error in ./src/index.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/index.js 5:13-29

Error in ./src/App.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/App.js 10:13-29

Error in ./src/Editor.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/Editor.js 10:13-29

Error in ./src/Fibers.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/Fibers.js 12:13-29

Error in ./src/index.js
Module not found: 'react-dom' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/index.js 9:16-36

Error in ./src/App.js
Module not found: 'react-noop-renderer' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\src

 @ ./src/App.js 18:25-55

Error in ./~/create-react-class/index.js
Module not found: 'react' in D:\WebStorm_workspace\react\fixtures\fiber-debugger\node_modules\create-react-class

 @ ./~/create-react-class/index.js 13:12-28

.......

I think this is because the loader can't find the corresponding modules,but if I press ctrl and click the linked module name,the IDE can find that in the dist directory,so I am a little confused,did you know how to solve this?

@mhhegazy
Copy link

@NE-SmallTown it work as desired on my environment.
its looks like .env file doesn't make effect on your environment I will take it spin and get back to you.

but this not related to this issue if your build end with all Diffs is 0% in this table then the build succeed.

react-build

@mhhegazy
Copy link

@NE-SmallTown where you run commands (CMD, PowerShell, bash or WebStorm Run)
If you run it from CMD try

$ set NODE_PATH=../../build/packages

then

$ npm start

and if you run it from WebStorm take a look here

@NE-SmallTown
Copy link
Contributor Author

@mhhegazy It works for me.Thanks a lot! 😃

@gaearon
Copy link
Collaborator

gaearon commented Jul 11, 2017

What's the next steps here? Any PRs we should merge?

This was referenced Sep 30, 2017
@mhhegazy
Copy link

@gaearon I've created PR #10982 please review it

@Kylesmile83
Copy link

Kylesmile83 commented Sep 30, 2017 via email

@gaearon gaearon changed the title Can't build React on Windows Can't build or test React on Windows Oct 4, 2017
@gaearon gaearon changed the title Can't build or test React on Windows Can't contribute to React on Windows Oct 4, 2017
@gaearon
Copy link
Collaborator

gaearon commented Oct 4, 2017

Let's make sure we also fix:

  • testing
  • linting
  • running Flow

and really anything that's broken now.

@mhhegazy
Copy link

mhhegazy commented Oct 6, 2017

@gaearon
All scripts running correctly expect:

[screenshots: left is Windows and right is Ubuntu]


$ yarn linc

linc

windows doesn't have grep command


$ yarn prettier-all

prettier-all

issue #9500 (a too long command) and PR #9523


here is the output of rest:

$ yarn build

fixed in PR #10982

Windows:
build-windows

Ubuntu:
build-linux


$ yarn lint

lint


$ yarn test

test


$ yarn flow

flow


$ yarn prettier

prettier

@wublack
Copy link

wublack commented Nov 3, 2017

it`s like same quastion ,when execute command npm run build .
image

@gaearon
Copy link
Collaborator

gaearon commented Nov 3, 2017

I verified yarn build works on Windows with Node 8 so I’ll close this.
#9500 still needs a solution so keeping it open.

I don't care strongly about linc but if somebody can get it working cross platform that would be great.

@gaearon
Copy link
Collaborator

gaearon commented Nov 29, 2017

OK. Hopefully this shouldn't become an issue in the future as we now run the build and tests on CI.
Sorry this used to be a problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants