Skip to content

Commit 95ca079

Browse files
author
Brian Vaughn
committed
Fixed standalone bug that prevented backend from being served over localhost:8097
1 parent 95ffd3c commit 95ca079

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react-devtools-core/src/standalone.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Bridge from 'src/bridge';
1111
import Store from 'src/devtools/store';
1212
import { getSavedComponentFilters, getAppendComponentStack } from 'src/utils';
1313
import { Server } from 'ws';
14+
import { join } from 'path';
1415
import { existsSync, readFileSync } from 'fs';
1516
import { installHook } from 'src/hook';
1617
import DevTools from 'src/devtools/views/DevTools';
@@ -258,9 +259,10 @@ function startServer(port?: number = 8097) {
258259
httpServer.on('request', (request, response) => {
259260
// NPM installs should read from node_modules,
260261
// 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+
}
264266

265267
// Serve a file that immediately sets up the connection.
266268
const backendFile = readFileSync(`${basePath}/dist/backend.js`);

0 commit comments

Comments
 (0)