Fixed standalone bug that prevented backend from being served over localhost:8097
Brian Vaughn committed
Aug 17, 2019 at 21:11 UTC
95ca079556b6aa86b15c3ba98e5b9a302e5fb646
1 file changed
+5
-3
packages/react-devtools-core/src/standalone.js
+5
-3
@@ -11,6 +11,7 @@ import Bridge from 'src/bridge';
11
import Store from 'src/devtools/store';
12
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
13
import { Server } from 'ws';
14
+import { join } from 'path';
15
import { existsSync, readFileSync } from 'fs';
16
import { installHook } from 'src/hook';
17
import DevTools from 'src/devtools/views/DevTools';
@@ -258,9 +259,10 @@ function startServer(port?: number = 8097) {
259
httpServer.on('request', (request, response) => {
260
// NPM installs should read from node_modules,
261
// But local dev mode needs to use a relative path.
261
- const basePath = existsSync('./node_modules/react-devtools-core')
262
- ? 'node_modules/react-devtools-core'
263
- : '../react-devtools-core';
262
+ let basePath = join(__dirname, 'node_modules/react-devtools-core');
263
+ if (!existsSync(basePath)) {
264
+ basePath = '../react-devtools-core';
265
+ }
266
267
// Serve a file that immediately sets up the connection.
268
const backendFile = readFileSync(`${basePath}/dist/backend.js`);