react: Can't contribute to React on Windows

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

> react-build@16.0.0-alpha.11 build D:\WebStorm_workspace\react
> npm run version-check && node scripts/rollup/build.js

> react-build@16.0.0-alpha.11 build D:\WebStorm_workspace\react
> npm run version-check && node scripts/rollup/build.js


> react-build@16.0.0-alpha.11 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! react-build@16.0.0-alpha.11 build: `npm run version-check && node scripts/rollup/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-build@16.0.0-alpha.11 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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (7 by maintainers)

Most upvoted comments

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 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

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

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

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