react-devtools icon indicating copy to clipboard operation
react-devtools copied to clipboard

Can't build on Windows

Open raulpineda opened this issue 9 years ago • 7 comments

When running npm run build:extension on Windows an error is raised stating

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at relative (path.js:559:5)
    at relativePath (C:\tools\react-devtools\shells\webextension\build.js:24:71)
    at main (C:\tools\react-devtools\shells\webextension\build.js:98:31)
    at <anonymous>

It is caused by process.env.PWD is undefined in this line of shells/webextension/build.js const relativePath = path => relative(process.env.PWD, path);

Hunch: It could be fixed by using __dirname instead, like shells/chrome/build.js does.

raulpineda avatar Oct 06 '17 13:10 raulpineda

Even with that PR fix, building on Windows will still fail:

PS C:\Users\User\Desktop\react-devtools-2.5.2> npm run build:extension:chrome

> @ build:extension:chrome C:\Users\User\Desktop\react-devtools-2.5.2
> node ./shells/chrome/build

✓ Preparing build
{ ChildProcessError: Command failed: NODE_ENV=production C:\Users\User\Desktop\react-devtools-2.5.2\node_modules\.bin\webpack --config webpack.config.js --output-path C:\Users\User\Desktop\react-devtools-2.5.2\shells\webextension\build\chrome\bin
'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.
 `NODE_ENV=production C:\Users\User\Desktop\react-devtools-2.5.2\node_modules\.bin\webpack --config webpack.config.js --output-path C:\Users\User\Desktop\react-devtools-2.5.2\shells\webextension\build\chrome\bin` (exited with error code 1)
    at callback (C:\Users\User\Desktop\react-devtools-2.5.2\node_modules\child-process-promise\lib\index.js:33:27)
    at ChildProcess.exithandler (child_process.js:278:5)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:927:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
  name: 'ChildProcessError',
  code: 1,
  childProcess:
   { ChildProcess: { [Function: ChildProcess] super_: [Object] },
     fork: [Function],
     _forkChild: [Function],
     exec: [Function],
     execFile: [Function],
     spawn: [Function],
     spawnSync: [Function: spawnSync],
     execFileSync: [Function: execFileSync],
     execSync: [Function: execSync] },
  stdout: '',
  stderr: '\'NODE_ENV\' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build:extension:chrome: `node ./shells/chrome/build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ build:extension:chrome script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2017-10-19T12_43_54_063Z-debug.log

Problem is these two lines, maybe need to use cross-env: https://github.com/facebook/react-devtools/blob/7062b52f13481f575988135ff33cd53fa7645894/shells/webextension/build.js#L57-L58

ngyikp avatar Oct 19 '17 12:10 ngyikp

cant't fix the problem ,how to config exactly!

mulholland0318 avatar Oct 23 '17 05:10 mulholland0318

+1, I can not fix this problem (OS Windows)

fourteenmeister avatar Nov 10 '17 09:11 fourteenmeister

+1, I can not fix this problem (OS Windows)

baokuanze avatar Jan 11 '18 10:01 baokuanze

+1, I can not fix this problem (OS Windows)

typistZxd avatar Jan 19 '18 01:01 typistZxd

+1, I can not fix this problem (OS Windows)

HannibalKcc avatar Feb 05 '18 10:02 HannibalKcc

I managed to monkey-patch the build script on windows to make the build working:

Change these two lines: https://github.com/facebook/react-devtools/blob/7062b52f13481f575988135ff33cd53fa7645894/shells/webextension/build.js#L57-L58

To this:

await exec('SET NODE_ENV=production');
await exec(`${webpackPath} --config webpack.config.js --output-path ${binPath}`, {cwd: __dirname});
await exec(`${webpackPath} --config webpack.backend.js --output-path ${binPath}`, {cwd: __dirname});

Paratron avatar Feb 07 '18 11:02 Paratron