From 710b443af1173b927d16efa9aa3f82020d4dfb8f Mon Sep 17 00:00:00 2001 From: Bram Date: Fri, 27 Nov 2015 07:15:28 -0800 Subject: [PATCH] bugfix #3997: react-native bundle not working on windows 10 Summary: fixes https://github.com/facebook/react-native/issues/3997 the root cause is in Mon, 09 Nov 2015 13:22:47 GMT ReactNativePackager:SocketServer uncaught error Error: listen EACCES C:\Users\donald\AppData\Local\Temp\react-packager-9248a9803ac72b509b389b456696850d This means that the socket server cannot create the socket. cfr https://gist.github.com/domenic/2790533 the socket name is not a valid windows socket name. Closes https://github.com/facebook/react-native/pull/4071 Reviewed By: mkonicek Differential Revision: D2699546 Pulled By: davidaurelio fb-gh-sync-id: 6c6494c14c42bb17506b8559001419c9f85e91e3 --- local-cli/bundle/saveAssets.js | 4 ++-- package.json | 1 + packager/react-packager/src/SocketInterface/index.js | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/local-cli/bundle/saveAssets.js b/local-cli/bundle/saveAssets.js index 1dd88512b..f95cd4c16 100644 --- a/local-cli/bundle/saveAssets.js +++ b/local-cli/bundle/saveAssets.js @@ -8,11 +8,11 @@ */ 'use strict'; -const execFile = require('child_process').execFile; const fs = require('fs'); const getAssetDestPathAndroid = require('./getAssetDestPathAndroid'); const getAssetDestPathIOS = require('./getAssetDestPathIOS'); const log = require('../util/log').out('bundle'); +const mkdirp = require('mkdirp'); const path = require('path'); function saveAssets( @@ -70,7 +70,7 @@ function copyAll(filesToCopy) { function copy(src, dest, callback) { const destDir = path.dirname(dest); - execFile('mkdir', ['-p', destDir], err => { + mkdirp(destDir, err => { if (err) { return callback(err); } diff --git a/package.json b/package.json index b3f5727f7..5be50c910 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "joi": "^6.6.1", "json5": "^0.4.0", "jstransform": "^11.0.3", + "mkdirp": "^0.5.0", "module-deps": "^3.9.1", "node-fetch": "^1.3.3", "opn": "^3.0.2", diff --git a/packager/react-packager/src/SocketInterface/index.js b/packager/react-packager/src/SocketInterface/index.js index c56026ead..32e3688c3 100644 --- a/packager/react-packager/src/SocketInterface/index.js +++ b/packager/react-packager/src/SocketInterface/index.js @@ -35,10 +35,17 @@ const SocketInterface = { } }); - const sockPath = path.join( + let sockPath = path.join( tmpdir, 'react-packager-' + hash.digest('hex') ); + if (process.platform === 'win32'){ + // on Windows, use a named pipe, convert sockPath into a valid pipe name + // based on https://gist.github.com/domenic/2790533 + sockPath = sockPath.replace(/^\//, '') + sockPath = sockPath.replace(/\//g, '-') + sockPath = '\\\\.\\pipe\\' + sockPath + } if (fs.existsSync(sockPath)) { var sock = net.connect(sockPath);