Comments (4)
This looks like a problem with your build tool. You should open an issue there instead. node:os
is a valid module specifier.
from fix-path.
Solution:
based on fix-path 4.0.0
import { execSync } from 'child_process';
import { userInfo } from 'os';
import process from 'process';
import stripAnsi from 'strip-ansi';
const defaultShell = (() => {
const { env, platform } = process;
if (platform === 'win32') {
return env.COMSPEC ?? 'cmd.exe';
}
try {
const { shell } = userInfo();
if (shell !== undefined) {
return shell;
}
} catch {}
if (platform === 'darwin') {
return env.SHELL ?? '/bin/zsh';
}
return env.SHELL ?? '/bin/sh';
})();
const arguments_ = ['-ilc', 'echo -n "_SHELL_ENV_DELIMITER_"; env; echo -n "_SHELL_ENV_DELIMITER_"; exit'];
const environment = {
// Disables Oh My Zsh auto-update thing that can block the process.
DISABLE_AUTO_UPDATE: 'true',
};
const parseEnvironment = (environment_: string): Record<string, string> => {
environment_ = environment_.split('_SHELL_ENV_DELIMITER_')[1];
const returnValue: Record<string, string> = {};
for (const line of stripAnsi(environment_)
.split('\n')
.filter((line) => Boolean(line))) {
const [key, ...values] = line.split('=');
returnValue[key] = values.join('=');
}
return returnValue;
};
export function shellEnvironmentSync(shell?: string): NodeJS.ProcessEnv {
if (process.platform === 'win32') {
return process.env;
}
try {
const stdout = execSync(`${shell ?? defaultShell} ${arguments_.join(' ')}`, { env: environment });
return parseEnvironment(String(stdout));
} catch (error) {
if (shell !== undefined) {
throw error;
} else {
return process.env;
}
}
}
export function shellPathSync(): string | undefined {
const { PATH } = shellEnvironmentSync();
return PATH;
}
export function fixPath(): void {
if (process.platform === 'win32') {
return;
}
process.env.PATH = shellPathSync() ?? ['./node_modules/.bin', '/.nodebrew/current/bin', '/usr/local/bin', process.env.PATH].join(':');
}
from fix-path.
https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
from fix-path.
So finally how to solve this? I got .webpack/main/454.index.worker.js Error: Cannot find module 'node:process'
from fix-path.
Related Issues (14)
- Ubuntu Linux Also ? HOT 4
- Fix-path breaks quit from dock in packaged electron app on OSX HOT 4
- Webpack warning: Module not found: Error: Can't resolve 'spawn-sync'
- ES Module import error HOT 2
- Must use import to load ES Module HOT 1
- how to use with require() ? HOT 4
- Get $PATH from the real shell HOT 1
- Different PATH with fixPath compared to $PATH in terminal? HOT 17
- Path not being fixed HOT 33
- ANSI codes appear in process.env.PATH after fix-path HOT 19
- Unexpected token error HOT 7
- No effect in PATH? HOT 2
- Implement $PATH detection using `/usr/libexec/path_helper` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fix-path.