Activating extension failed: 无法找到模块 ‘glob’

huangapple go评论61阅读模式
英文:

Activating extension failed: Cannot find module 'glob'

问题

I'll provide the translations for the code-related portions you've provided:

  • Developing a VS Code extension: 开发一个 VS Code 扩展。
  • When testing the extension locally: 在本地测试扩展时。
  • everything works perfectly: 一切都运行正常。
  • But when I publish the extension: 但当我发布扩展时。
  • I get an error saying: 我收到一个错误消息,其中包含。
  • I also get a popup error saying: 我还会收到一个弹出窗口错误,其中包含。
  • This is my package.json dependencies: 这是我的 package.json 依赖项。
  • Here is my tsconfig.json: 这是我的 tsconfig.json。

For the code snippets, I won't provide translations for the content within them, as they seem to be code and should remain in the original language. If you have any specific code-related questions or need further assistance, feel free to ask.

英文:

Developing a VS Code extension. When testing the extension locally in my developer window, everything works perfectly. But when I publish the extension in the marketplace, I get an error saying:

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.

I also get a popup error saying:

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

This is my package.json dependencies:

  "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"
  }

Here is my 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"
	]
}

I tried running various commands like npm install glob or npm install --save-dev glob. I've tried deleting and recreating node_modules directory. I've tried uninstalling and reinstalling npm.

答案1

得分: 2

移除devDependencies中的glob解决了我的问题。通常情况下,在dependencies和devDependencies中使用相同版本的同一库不应该引发任何问题,但在这种情况下却出现了问题。

英文:

Had the same issue: Removing glob from devDependencies solved it for me.

Normally, having the same library with the same version in both dependencies and devDependencies shouldn't cause any problems but in this particular case it does for some reason.

huangapple
  • 本文由 发表于 2023年4月11日 06:35:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981223.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定