Skip to content

Commit 550e1a7

Browse files
committed
fix: double require problem
1 parent 1d26974 commit 550e1a7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bin/webpack-dev-server.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ const runCommand = (command, args) => {
3737
*/
3838
const isInstalled = (packageName) => {
3939
try {
40-
require.resolve(packageName);
41-
42-
return true;
40+
// Importing here as done in runCommand()
41+
const { execSync } = require('child_process');
42+
const { resolve } = require('path');
43+
const { statSync } = require('fs');
44+
45+
const rootPath = execSync('npm root', { encoding: 'utf8' }).trimEnd();
46+
const packageStats = statSync(resolve(rootPath, `./${packageName}`));
47+
return packageStats.isDirectory();
4348
} catch (err) {
4449
return false;
4550
}

0 commit comments

Comments
 (0)