所以我使用yeoman生成的vs代码扩展中的vscode节点模块没有问题。
但有没有理由说这个模块似乎只是用一个简单的新脚本来测试呢?
我的代码中没有智能感知错误,而我的vscode.d.ts文件就是它应该存在的位置。
index.ts:
import * as vscode from "vscode";
console.log(vscode);
index.js:
"use strict";
exports.__esModule = true;
var vscode = require("vscode");
console.log(vscode);
的package.json:
{
"name": "vscodetemp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"author": "",
"license": "ISC",
"engines": {
"vscode": "^1.13.0"
},
"devDependencies": {
"vscode": "^1.0.0"
}
}
例外:
module.js:471
throw err;
^
Error: Cannot find module 'vscode'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\temp\vscodeTemp\index.js:3:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
https://github.com/Microsoft/vscode-extension-vscode/issues/68#issuecomment-311860868
答案 0 :(得分:1)
不幸的是,这不起作用,因为vscode“node_module”实现只能从vscode运行时中访问。更多信息:https://github.com/Microsoft/vscode/issues/6586。