docmirror/dev-sidecar · warning
暂未实现此功能
Error message
暂未实现此功能
What it means
set-npm-env configures npm proxy-related settings by shelling out to `npm config set`. Only the Windows executor is implemented; the linux executor is a stub that unconditionally throws this 'not yet implemented' placeholder. It is a deliberate feature gap, not a runtime failure of your input.
Source
Thrown at packages/core/src/shell/scripts/set-npm-env.js:17
/**
* 设置环境变量
*/
const Shell = require('../shell')
const execute = Shell.execute
const executor = {
async windows (exec, { list }) {
const cmds = []
for (const item of list) {
cmds.push(`npm config set ${item.key} ${item.value}`)
}
return await exec(cmds, { type: 'cmd' })
},
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
- Set the npm config manually: `npm config set proxy http://127.0.0.1:<port>` and `npm config set https-proxy http://127.0.0.1:<port>`.
- Or use environment variables instead: export HTTP_PROXY/HTTPS_PROXY pointing at the local dev-sidecar port.
- Contribute/patch the linux executor in packages/core/src/shell/scripts/set-npm-env.js to run the same `npm config set` commands via exec.
- Run the affected tooling under a platform where the feature exists (Windows) if practical.
Example fix
// before (stub in set-npm-env.js)
async linux (exec, { port }) {
throw new Error('暂未实现此功能')
}
// after (naive implementation mirroring the windows branch)
async linux (exec, { list }) {
const cmds = list.map(item => `npm config set ${item.key} ${item.value}`)
return exec(cmds, { type: 'cmd' })
} Defensive patterns
Strategy: fallback
Validate before calling
const os = require('os')
if (os.platform() !== 'win32') {
// set npm proxy manually instead of calling set-npm-env
const { execSync } = require('child_process')
execSync(`npm config set proxy http://127.0.0.1:${port}`)
execSync(`npm config set https-proxy http://127.0.0.1:${port}`)
} Type guard
null
Try / catch
try {
await setNpmEnv({ list })
} catch (e) {
if (e.message === '暂未实现此功能' && process.platform === 'linux') {
// fall back to env vars or direct npm config
process.env.HTTP_PROXY = `http://127.0.0.1:${port}`
process.env.HTTPS_PROXY = `http://127.0.0.1:${port}`
} else throw e
} Prevention
- Gate npm-env features on platform === 'win32' in your own code.
- Prefer HTTP(S)_PROXY environment variables on Linux — npm honors them without npm config changes.
- Check the package docs/issues for Linux support status before enabling the feature.
- Contribute the linux executor upstream rather than relying on the stub.
When it happens
Trigger: Calling the set-npm-env shell script (executor dispatch) with platform=linux — i.e. invoking DevSidecar's npm environment setup API on any Linux system.
Common situations: Running dev-sidecar or the CLI on a Linux server/desktop where the app tries to point npm at the local proxy; CI pipelines on Linux runners; WSL sessions detected as Linux.
Related errors
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/adcaf56bee5dd7e0.
Report an issue: GitHub.