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
Yes, the build is likely broken on Windows right now.
Probably a duplicate of https://github.com/facebook/react/issues/9350.
Can you look into where it breaks? We should file more issues with Rollup if it’s their bug.
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.
@gaearon Hi dan,is there any progress on this?
No, we’re not using Windows, and would like to get community help on this.
get it,so I will ask for help in other place,close now,if I find a solution,I will share and reopen
I'd like to keep it open to keep track of this being broken.
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":
require\('.+?'\)
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":
require("fbjs
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... ðŸ˜)
@Venryx Thanks for your attempt.
You say:
Pattern (regex):
require\('.+?'\)
I don't find it,is there any typo?
Build on windows issue has two parts:
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:
rollup-plugin-alias.js
in ./scripts/rollup/plugins
and paste in this./scripts/rollup/build.js
replace rollup-plugin-alias
with ./plugins/rollup-plugin-alias
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
@mhhegazy Greate work!Thanks a lot!!!Really much appreciated! :+1:
@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?
@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.
@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
@mhhegazy It works for me.Thanks a lot! :smiley:
What's the next steps here? Any PRs we should merge?
@gaearon I've created PR #10982 please review it
Get Outlook for iOShttps://aka.ms/o0ukef
From: Mohamed H. Hegazy notifications@github.com
Sent: Friday, September 29, 2017 11:02:11 PM
To: facebook/react
Cc: Subscribed
Subject: Re: [facebook/react] Can't build React on Windows (#9540)
@gaearonhttps://github.com/gaearon I've created PR #10982https://github.com/facebook/react/pull/10982 please review it
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/facebook/react/issues/9540#issuecomment-333278088, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcTxbk0OKT34PX8HWtz6hMeKbKmQEo7Wks5sna8zgaJpZM4NJyig.
Let's make sure we also fix:
and really anything that's broken now.
@gaearon
All scripts running correctly expect:
[screenshots: left is Windows and right is Ubuntu]
```bash
$ yarn linc

windows doesn't have grep command
---
```bash
$ yarn prettier-all
issue #9500 (a too long command) and PR #9523
```bash
$ yarn build
fixed in PR #10982
Windows:

Ubuntu:

---
```bash
$ yarn lint
```bash
$ yarn test

---
```bash
$ yarn flow
bash
$ yarn prettier
it`s like same quastion ,when execute command npm run build .
I verified yarn build
works on Windows with Node 8 so I’ll close this.
https://github.com/facebook/react/issues/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.
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!
Most helpful comment
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:
rollup-plugin-alias.js
in./scripts/rollup/plugins
and paste in this./scripts/rollup/build.js
replacerollup-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 normalizereplaceModules
paths (replace all\
with/
) before use it in rollup-plugin-replace.@Venryx @NE-SmallTown @teemosauce @ccsang please confirm this solve the issue