- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 VSCode 扩展开发非常陌生。所以这可能是一个微不足道的问题或已经讨论过的问题。但我无法让它发挥作用。所以我正在寻求帮助。
我目前正在构建一个非常简单的扩展。使用来自命令面板的命令(比方说:Light Me Up
),它会显示一个随机引用作为信息消息。
这就是我想要做的。我想从 here 中获取一堆引语然后将它们存储在一个变量中,然后每次触发命令时我想随机选择一个并显示它。
这是我的代码看起来像
import * as vscode from 'vscode';
import fetch from 'node-fetch';
// const got = require('got');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "seecode" is now active!');
let data;
(async () => {
const response = await fetch("https://zenquotes.io/api/quotes");
data = await response.json();
console.log(data);
})();
context.subscriptions.push(
vscode.commands.registerCommand('seecode.helloWorld', () => {
vscode.window.showInformationMessage('Hello from SeeCode! See you on the other side');
}
)
);
// context.subscriptions.push(vscode.commands.registerCommand('seecode.'));
}
这是我的 package.json
{
"name": "seecode",
"displayName": "SeeCode",
"description": "Easy Visual DevOPs",
"version": "0.0.1",
"engines": {
"vscode": "^1.63.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:seecode.helloWorld",
"onCommand:seecode.lightMeUp"
],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "seecode.helloWorld",
"title": "Hello World"
},
{
"command": "seecode.lightMeUp",
"category": "SeeCode",
"title": "Light Me Up"
}
]
},
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "14.x",
"@types/vscode": "^1.63.0",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"@vscode/test-electron": "^1.6.2",
"eslint": "^8.1.0",
"glob": "^7.1.7",
"mocha": "^9.1.3",
"ts-loader": "^9.2.5",
"typescript": "^4.4.4",
"webpack": "^5.52.1",
"webpack-cli": "^4.8.0"
},
"dependencies": {
"node-fetch": "^3.1.0"
}
}
当我尝试运行扩展时,它会打开第二个 VSCode 窗口,但如果我尝试从此处发出任何命令(假设是 Hello World
一个),则会出现以下错误
Activating extension 'undefined_publisher.seecode' failed:
Cannot find module 'node:http' Require stack:
- /home/shubhadeep/work/personal/vscode_extension/seecode/dist/extension.js
- /snap/code/85/usr/share/code/resources/app/out/vs/loader.js
- /snap/code/85/usr/share/code/resources/app/out/bootstrap-amd.js
- /snap/code/85/usr/share/code/resources/app/out/bootstrap-fork.js.
我该怎么做才能解决这个问题?我只想在控制台中查看 json。我在这里错过了什么?
最佳答案
从这两个问题来看:
Cannot find module 'node:http` on AWS Lambda v14和
Problem with importing node-fetch v3.0.0 and node v16.5.0
看起来从 node-fetch
v3 升级到 v3.1 是“麻烦的”,导致了您在某些方面看到的错误。
一些用户正在降级到 v2(或者您可以尝试 v3 而不是您正在使用的 v3.1)。
卸载 node-fetch
和npm install -s node-fetch@2
如评论中所述,如果您降级到 v2,您可能想要这样做
npm install -D @types/node-fetch@2
。
关于node.js - 获取 VSCode 扩展 : node-fetch and node:http issues,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70590704/
我不知道我做了什么来破坏我的 QtCreator,但是“突然”我所有的编译器问题(警告/错误)不再显示在问题面板中,而是只显示在“编译输出”面板中(我在那里不能使用它们通过单击跳转到错误代码)。 在“
我正在制作游戏作为自学。 我的目标是在鼠标指针后面有一条轨迹。(这有效)但是,当我在 chrome 上打开并运行它时。在达到一定的高度和宽度后,轨迹保留在 Canvas 上而不是被擦掉。谁能帮我解决这
我希望通过在我的HTML文件中适当地格式化我的网站上的文本来增强它的外观。具体地说,我希望确保我的HTML文件中的代码在网站上显示得很好。此外,我正在寻求帮助实现我的网站导航栏。,我希望和其他内容显示
我希望通过在我的HTML文件中适当地格式化我的网站上的文本来增强它的外观。具体地说,我希望确保我的HTML文件中的代码在网站上显示得很好。此外,我正在寻求帮助实现我的网站导航栏。,我希望和其他内容显示
我希望通过在我的HTML文件中适当地格式化我的网站上的文本来增强它的外观。具体地说,我希望确保我的HTML文件中的代码在网站上显示得很好。此外,我正在寻求帮助实现我的网站导航栏。,我希望和其他内容显示
我一直在尝试将背景图像添加到 html 文档中元素的边框: 你可以在这里看到:HTML: Something CSS: a { border-width:10px; border-co
我即将开始一个连接两个程序的项目,一个用c#,一个用c++。我已经有一个可以工作的 c# 程序,它能够与自身的其他版本对话。在开始使用c++版本之前,我想到了一些问题: 1) 我正在使用 protob
我正在尝试线程优先级的影响,当 run 方法中的 println 保留在注释中时,两个线程同时结束,我不理解这种行为,你能解释一下吗?谢谢。 主类 public class Main { public
jQuery 1.4: $('#menu li:last:not(.ignore)').addClass('last'); HTML: item 1 ite
当我创建或查看问题时,我想从Mantis问题跟踪系统中删除选择配置文件及其所有随附字段,因为这些问题与我要创建的任何问题都不相关。 其中包括配置文件部分随附的“平台”,“操作系统”和“操作系统版本”字
我不在Master分支上工作。我正在开发另一种newFeature,该功能也发布在github上。 我知道在处理Master分支时如何解决问题:Closes #XXX。 但是,这仅在我在Master分
我需要在一些UICollectionViewCell中画一个圆圈。具有不同颜色边框和背景颜色的圆圈。我的代码。 UICollectionViewController - (UICollectionVi
我们将Trac用于我正在从事的开源项目。我想将所有公开票导出到Github的Issues。我已经找到了一些可能的小型脚本,但是我想知道是否有人这样做并提出了建议。 理想情况下,它将trac的描述语法转
我对 iOS 编程还比较陌生,但在其他语言(主要是 C# 和 Java)方面拥有丰富的编程经验。 我正在尝试为 iPad 设备的某些产品制作一个类似图片库的东西,其中包含指定的类别。用户界面非常简单,
我已经在中间人中激活了 I18n,如下所示: activate :i18n, mount_at_root: :de 现在我想自动从 / 重定向到 /de。这可能吗? 另外,我想知道为什么中间人使用 p
我已经成功编写了一个程序,可以从 Excel 文件中读取数据并将它们存储在 mysql 的表中。我的程序读取每个文件的第一行,创建表的字段,并将其余数据存储为每列中的值。正是因为这种情况以编程方式发生
这是我的代码。 function m1() { return new Promise(function(resolve, reject) { var files = $('#aws-upl
谁能告诉我这是怎么回事? #include #include #include #include #include class writeManager { std::vector
compile 'com.github.RogaLabs:social-login:1.2.1' compile 'com.github.mukeshsolanki:social-login-help
我有一个巨大的 csv 文件,其中包含 149 列 和 25K+ 行,可以在 MySQL 中上传该文件> 我正在使用MySQL LOAD DATA 查询 表我的查询是: LOAD DATA local
我是一名优秀的程序员,十分优秀!