Make puter boot on windows (#2269)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled

This commit is contained in:
Neal Shah
2026-01-12 15:26:53 +05:30
committed by GitHub
parent 04901a7cd1
commit 8e6d3d8d9f
2 changed files with 21 additions and 6 deletions
+14 -5
View File
@@ -36,7 +36,7 @@ const { RuntimeModuleRegistry } = require('./extension/RuntimeModuleRegistry');
const { RuntimeModule } = require('./extension/RuntimeModule');
const deep_proto_merge = require('./config/deep_proto_merge');
const { kv } = require('./util/kvSingleton');
const url = require('url');
const { quot } = libs.string;
class Kernel extends AdvancedBase {
@@ -452,7 +452,7 @@ class Kernel extends AdvancedBase {
async _run_extern_mod (mod_entry) {
let exportObject = null;
const {
let {
module: mod,
require_dir,
context,
@@ -470,8 +470,14 @@ class Kernel extends AdvancedBase {
mod.extension.name = packageJSON.name;
// Platform normalization for if import is used in the place of require();
let importPath = path_.join(require_dir, packageJSON.main ?? 'index.js');
if ( process.platform === 'win32' ) {
importPath = (url.pathToFileURL(importPath)).href;
}
const maybe_promise = (typ => typ.trim().toLowerCase())(packageJSON.type ?? '') === 'module'
? await import(path_.join(require_dir, packageJSON.main ?? 'index.js'))
? await import(importPath)
: require(require_dir);
if ( maybe_promise && maybe_promise instanceof Promise ) {
@@ -582,8 +588,11 @@ class Kernel extends AdvancedBase {
}
async run_npm_install (path) {
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const proc = spawn(npmCmd, ['install'], { cwd: path, stdio: 'pipe' });
const npmOptions = process.platform === 'win32'
? ['npm.cmd', ['install'], { shell: true, cwd: path, stdio: 'pipe' }]
: ['npm', ['install'], { cwd: path, stdio: 'pipe' }];
const proc = spawn(...npmOptions);
let buffer = '';
@@ -21,6 +21,7 @@ const BaseService = require('../../services/BaseService');
const path_ = require('node:path');
const fs = require('node:fs');
const url = require('node:url');
class ProxyLogger {
constructor (log) {
@@ -131,7 +132,7 @@ class DevWatcherService extends BaseService {
['webpack.config.mjs', 'module'],
];
const {
let {
configjsPath: webpackConfigPath,
moduleType,
} = await this.get_configjs({
@@ -179,6 +180,11 @@ class DevWatcherService extends BaseService {
}
process.env = newEnv; // Yep, it totally lets us do this
}
if ( moduleType === 'module' && process.platform === 'win32' ) {
webpackConfigPath = url.pathToFileURL(webpackConfigPath).href;
}
let webpackConfig = moduleType === 'module'
? (await import(webpackConfigPath)).default
: require(webpackConfigPath);