{"record":{"id":"cb11cc3db905ab02","repo":"docmirror/dev-sidecar","slug":"error-cb11cc","errorCode":null,"errorMessage":"暂未实现此功能","messagePattern":"暂未实现此功能","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/shell/scripts/get-npm-env.js","lineNumber":19,"sourceCode":"/**\n * 获取环境变量\n */\nconst jsonApi = require('@docmirror/mitmproxy/src/json')\nconst Shell = require('../shell')\n\nconst execute = Shell.execute\n\nconst executor = {\n  async windows (exec) {\n    const ret = await exec(['npm config list --json'], { type: 'cmd' })\n    if (ret != null) {\n      const json = ret.substring(ret.indexOf('{'))\n      return jsonApi.parse(json)\n    }\n    return {}\n  },\n  async linux (exec, { port }) {\n    throw new Error('暂未实现此功能')\n  },\n  async mac (exec, { port }) {\n    throw new Error('暂未实现此功能')\n  },\n}\n\nmodule.exports = async function (args) {\n  return execute(executor, args)\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/get-npm-env.js#L1-L29","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Node plugin GUI page on a Linux desktop trying to read npm environment; shared automation that reads npm env across platforms.","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."],"exampleFix":"// before\nconst env = await DevSidecar.shell.getNpmEnv({ port })\n// after\nlet env = {}\nif (process.platform === 'win32') {\n  env = await DevSidecar.shell.getNpmEnv({ port })\n} else {\n  const { execSync } = require('child_process')\n  env = JSON.parse(execSync('npm config list --json').toString())\n}","handlingStrategy":"fallback","validationCode":"if (process.platform === 'win32') {\n  const env = await DevSidecar.shell.getNpmEnv({ port })\n} else {\n  const env = JSON.parse(require('child_process').execSync('npm config list --json').toString())\n}","typeGuard":"function supportsNpmEnvHelper () {\n  return process.platform === 'win32'\n}","tryCatchPattern":"try {\n  env = await DevSidecar.shell.getNpmEnv({ port })\n} catch (err) {\n  if (err.message === '暂未实现此功能') {\n    env = JSON.parse(execSync('npm config list --json').toString())\n  } else { throw err }\n}","preventionTips":["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"],"tags":["platform-unsupported","linux","npm","not-implemented"],"backgroundTag":"feature-not-implemented","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}