docmirror/dev-sidecar · warning
暂未实现此功能
Error message
暂未实现此功能
What it means
`get-npm-env` exposes a shell helper that returns the npm environment (registry/proxy settings) by invoking npm commands. Only the Windows handler is implemented; `linux` throws `暂未实现此功能` (not yet implemented). It is a known feature gap, not a runtime fault.
Source
Thrown at packages/core/src/shell/scripts/get-npm-env.js:19
/**
* 获取环境变量
*/
const jsonApi = require('@docmirror/mitmproxy/src/json')
const Shell = require('../shell')
const execute = Shell.execute
const executor = {
async windows (exec) {
const ret = await exec(['npm config list --json'], { type: 'cmd' })
if (ret != null) {
const json = ret.substring(ret.indexOf('{'))
return jsonApi.parse(json)
}
return {}
},
async linux (exec, { port }) {
throw new Error('暂未实现此功能')
},
async mac (exec, { port }) {
throw new Error('暂未实现此功能')
},
}
module.exports = async function (args) {
return execute(executor, args)
}
View on GitHub (pinned to 7710cd56cc)
Solutions
- Implement the linux handler: run `npm config get registry`/`npm config list --json` and parse with jsonApi, mirroring the win handler.
- Read npm config directly in your own code (`npm config list --json` via child_process) instead of the library helper.
- Use this helper only on Windows; feature-detect by platform first.
Example fix
// before
const env = await DevSidecar.shell.getNpmEnv({ port })
// after
let env = {}
if (process.platform === 'win32') {
env = await DevSidecar.shell.getNpmEnv({ port })
} else {
const { execSync } = require('child_process')
env = JSON.parse(execSync('npm config list --json').toString())
} Defensive patterns
Strategy: fallback
Validate before calling
if (process.platform === 'win32') {
const env = await DevSidecar.shell.getNpmEnv({ port })
} else {
const env = JSON.parse(require('child_process').execSync('npm config list --json').toString())
} Type guard
function supportsNpmEnvHelper () {
return process.platform === 'win32'
} Try / catch
try {
env = await DevSidecar.shell.getNpmEnv({ port })
} catch (err) {
if (err.message === '暂未实现此功能') {
env = JSON.parse(execSync('npm config list --json').toString())
} else { throw err }
} Prevention
- Read npm config directly via `npm config list --json` on non-Windows
- Check platform before using shell helpers
- Pin a fork/patch if you need the helper cross-platform
When it happens
Trigger: Calling the get-npm-env shell API (e.g. `DevSidecar.shell.getNpmEnv`) on Linux, which dispatches to the placeholder `linux` handler in packages/core/src/shell/scripts/get-npm-env.js:19.
Common situations: Node plugin GUI page on a Linux desktop trying to read npm environment; shared automation that reads npm env across platforms.
Related errors
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/cb11cc3db905ab02.
Report an issue: GitHub.