我正在开发一个 VSCode 扩展来自动化一些编辑和搜索过程。一切运行正常!在扩展开发主机中,但是当我尝试将扩展与 vsce 打包到扩展的文件夹中时,应用程序响应此错误:
ERROR Extension entrypoint(s) missing. Make sure these files exist and aren't ignored by '.vscodeignore':
extension/extension.js
在扩展的清单(package.json)中,扩展代码的入口点在“main”键中定义:
...
"activationEvents": [
"onCommand:extension.findBlock"
],
"main": "./extension.js",
"contributes": {
"commands": [
{
"command": "extension.findBlock",
"title": "Find Block"
}
],
...
在扩展的文件夹中,一切都与 Visual Studio 扩展生成器(yo)留下的一样。
.
├── block_finder.code-workspace
├── CHANGELOG.md
├── extension.js
├── findBlock.png
├── jsconfig.json
├── node_modules
├── package.json
├── package-lock.json
├── prueba.txt
├── README.md
├── test
└── vsc-extension-quickstart.md
我错过了什么吗?我不明白会发生什么。我的VSCode版本是1.65.2,vsce是2.7.0。谢谢!
我回来说我通过卸载npm管理器解决了这个问题。我安装的版本很旧,我注意到在安装扩展需求时,它安装的软件包带有已弃用版本的警告。我卸载了 npm 并进行了全新安装,我的扩展开始按预期工作。很抱歉让这篇文章保持开放状态,并感谢您给我的所有帮助。
我花了一周时间试图解决这个问题。 事实证明解决方案非常简单。 从操作系统中卸载 Node.js 和 npm。 安装我当前正在使用的最新版本的 Node.js:
节点-v
v20.3.1
npm -v
9.7.2
这立即解决了我的问题。 如果再次发生,可能值得考虑使用更新的版本。
就我而言,我有以下
.vscodeignore
文件:
# Ignore everything
**
# Include specific files
!/out/*
!/CHANGELOG.md
!/LICENSE.md
!/package.json
!/README.md
删除所有
/
前缀解决了问题:
# Ignore everything
**
# Include specific files
!out/*
!CONTRIBUTING.md
!CHANGELOG.md
!LICENSE.md
!package.json
!README.md