激活扩展失败:找不到模块“glob”

问题描述 投票:0回答:1

开发 VS 代码扩展。在我的开发人员窗口中本地测试扩展时,一切正常。但是当我在市场上发布扩展时,我收到一条错误消息:

mainThreadExtensionService.ts:112 Activating extension 'Massdriver.vscode-massdriver-tools' failed: Cannot find module 'glob'
Require stack:
- /home/michael/.vscode-server/extensions/test.vscode-ex-tools-0.0.4/out/terraform/deploy.js
- /home/michael/.vscode-server/extensions/test.vscode-ex-tools-0.0.4/out/extension.js
- /home/michael/.vscode-server/bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/out/vs/loader.js
- /home/michael/.vscode-server/bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/out/bootstrap-amd.js
- /home/michael/.vscode-server/bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/out/bootstrap-fork.js.

我也收到一个弹出错误说:

Command 'Ex:Action One' resulted in an error
command 'ex:actionone' not found

这是我的

package.json
依赖项:

  "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"
  },
  "dependencies": {
    "fs": "^0.0.1-security",
    "path": "^0.12.7",
    "semver": "^7.3.8",
    "glob": "^10.0.0"
  },
  "devDependencies": {
    "@types/glob": "^8.0.0",
    "@types/mocha": "^10.0.0",
    "@types/node": "16.x",
    "@types/vscode": "^1.72.0",
    "@typescript-eslint/eslint-plugin": "^5.38.1",
    "@typescript-eslint/parser": "^5.38.1",
    "@vscode/test-electron": "^2.1.5",
    "eslint": "^8.26.0",
    "glob": "^10.0.0",
    "typescript": "^4.8.4"
  }

这是我的 tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES2020",
        "outDir": "out",
        "lib": [
            "ES2020"
        ],
        "sourceMap": true,
        "rootDir": "src",
        "strict": true,
        "esModuleInterop": true,
        "skipLibCheck": true 
        /* enable all strict type-checking options */
        /* Additional Checks */
        // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
        // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
        // "noUnusedParameters": true,  /* Report errors on unused parameters. */
    },
    "exclude": [
        "node_modules",
        ".vscode-test"
    ]
}

我尝试运行各种命令,例如

npm install glob
npm install --save-dev glob
。我试过删除并重新创建
node_modules
目录。我试过卸载并重新安装 npm。

npm vscode-extensions glob
1个回答
0
投票

有同样的问题,从 devDependencies 中删除 glob 为我解决了它。

通常情况下,在 dependencies 和 devDependencies 中拥有相同版本的相同库不会造成任何问题,但在这种特殊情况下,由于某种原因它会造成问题。

© www.soinside.com 2019 - 2024. All rights reserved.