Tag: visual studio code

为什么VS代码在使用步骤时进入Node.js内部代码

在这个例子代码中debugging,每次按下f10(step over),debugging器会input一个文件名next_tick.js,它是一个与Node.js相关的文件。 为什么? 我不想进入与Node.js相关的内部代码。 以下是示例代码 function abc() { return new Promise((resolve, reject) => { setTimeout(function () { resolve(10) }, 1000) }); } async function b(){ const a=10+ await abc() console.log(a) } b() 以下是next_tick.js的一部分 // Run callbacks that have no domain. // Using domains will cause this to be overridden. function _tickCallback() { do { while […]

使用VS代码debugging器不能将断点设置为打字稿

我的项目有以下结构 .vscode | |____launch.json dist | |____server.js | |____server.js.map node_modules src | |____server.ts gulpfile.js package.json tsconfig.json 我的launch.json是 { "version": "0.2.0", "configurations": [ { "name": "Attach", "type": "node", "request": "attach", "port": 9229, "address": "localhost", "restart": false, "sourceMaps": true, "outFiles": ["${workspaceRoot}/dist/**/*.js"], "localRoot": "${workspaceRoot}/src/**/*.js", "remoteRoot": null, "protocol": "inspector" } ] } 我的gulpfile.js是 const gulp = require('gulp'); const ts […]

在debugging控制台中探索承诺值

在debuggingvscode中的节点进程时,我可以编写任意expression式在debugging控制台中进行评估。 但是,如果我写出返回Promise的expression式,我不知道如何获得价值。 例如,探索调用返回promise的模型函数的数据库是什么方法。 我试过了 Format.all(context.engine).then(formats => console.log(formats)) 但是仍然只能得到Promise对象而不是要解决的价值。

在编辑器中从Docker容器中的编译代码获取intellisense

我一直在寻找这一点,但似乎无法find一个体面的解决scheme,而不会在我的工作区中创build额外的混乱。 是否有可能使用编辑器,如VSCode,并使其intellisense使用驻留在docker容器 (或多个)内的编译代码? 通过创build链接node_modules和编译的文件夹的共享卷,可能达到的一种方法就是这样做。 在我的工作区中,我正在使用NodeJS,Npm模块,而我select的编辑器是Visual Studio代码。 使用docker-compose启动工作区设置 任何build议是值得欢迎的

为什么VS代码在Promise中拒绝处理exception?

拿这个代码,我们有一个承诺,调用一个失败的函数,它应该把错误传递给承诺的catch方法。 从terminal上跑时它工作得很好。 但是,当通过vscode运行时,它在(1)处爆炸。 function failingFunc() { let undef = undefined; return undef.nope(); } let promise = new Promise((resolve, reject) => { resolve(failingFunc()); // (1) Explodes when run from vscode }); promise.then(v => {}).catch((e: Error) => { console.log(e.message); // (2) Prints when run from the terminal }); 为什么是这样? 关于页面的vscode: 版本1.14.2 提交cb82feb date2017-07-19T23:26:08.116Z 壳牌1.6.6 渲染器56.0.2924.87 节点7.4.0

在VS Codedebugging器中使用旧版本的节点

我将VS Code更新为1.14.2,并试图运行需要Node 6.x的应用程序。 在此更新之前,我使用的configuration工作得很好: { "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceRoot}/keystone.js" }, { "type": "node", "request": "attach", "name": "Attach to Port", "address": "localhost", "port": 5858 } ] } 现在,当我执行程序时,它只是挂起而没有启动(预计当我使用Node 7.x或更高版本运行时)。 此外,它还提供以下消息,我不确定是否相关: 使用检查器协议进行debugging,因为检测到Node.js v8.2.1。 node –inspect = 38743 –debug-brk keystone.js 在ws://127.0.0.1:38743 / d4a20480-3a0f-4aa7-8882-aec756edd6dadebugging器上侦听附加的debugging器。 我正在使用nvm来pipe理我的节点版本, nvm list提供了以下内容(正如你所看到的,我已经有6.11.0别名为默认值): $ nvm […]

在VS代码中debuggingTypescript / Javsacript Mongodb会给出错误:ENOTDIR:不是目录stat

Mac OS 10.12.6,来自brew v8.5.0的节点,用brew安装的npm v5.3.0,Visual Studio Code v1.16.1,tsc 2.4.1 我正在尝试运行以下代码片段: import { MongoClient } from 'mongodb'; MongoClient.connect('<url>', (err, db) => console.log(err) ); 在运行带节点的程序的bashterminal中, 给出预期的结果 :null。 但在Visual Studio代码中,使用以下debuggingconfiguration: "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceRoot}/src/17_Mongo.js" 给出以下错误: Error: ENOTDIR: not a directory, stat '/Users/alexbjorlig/Documents/SolidFlow/streamRD/node_modules/mongodb-core/index.js/package.json' at fs.existsSync (fs.js:329:13) at find_package_json (/Users/alexbjorlig/Documents/SolidFlow/streamRD/node_modules/require_optional/index.js:14:9) at find_package_json_with_name (/Users/alexbjorlig/Documents/SolidFlow/streamRD/node_modules/require_optional/index.js:34:20) at require_optional […]

使用VSCode在浏览器中debugging简单的Typescript应用程序

我正在构build我的第一个打字稿项目(我的背景是C#,Java)。这些应用程序按预期工作,但是我不能在打字稿中放置一个断点并debugging应用程序。 此外,当我使用纯打字机编译器(tscs与tsc.exe)映射完美的作品。 我正在使用gulp,因为我想将所有js放入一个文件中。 当生成的js中有一个错误,那么Visual Studio代码打击js文件(bundle.js)中的断点而不是打字稿,但是自定义断点不工作 我正在使用Windows 10进行开发。 请在下面find我的代码。 HTML 的index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Hello World!</title> <!– <script data-main="main" src="scripts/require.js"></script> –> </head> <body> <p id="greeting">Loading …</p> <script src="bundle.js"></script> </body> </html> 键入脚本 main.ts import { Student } from "./student"; class Startup { public static main(): string { return Startup.showHello(); } public static showHello() […]

Visual Studio Code&node.js:debugging器退出,没有错误信息

节点v4.2.6,VS代码0.10.6,Windows 8.1 调用带有复杂对象的“console.log”时,VS代码不会出现任何错误消息。 调用相同的代码没有控制台行工作正常。 当跨越代码行时,对象被打印到输出窗口,但是debugging器退出。 VS代码不会在“variables”和“输出”窗格中显示任何错误消息。 任何帮助表示赞赏, 谢谢 格拉。

如何获取VS Code intellisense来search多个node_modules文件夹中的打字稿

我有一个像这样的结构/打字稿项目: – node_modules // => these are loaded npm/package.json – src – node_modules // => shared modules for my project, not on npm – lib.ts – app.ts – package.json 我有一个辅助node_modules文件夹为我的私人包主要是所以我可以从我的项目中的任何地方导入他们,而不必担心导入相对path( 这里build议 )。 这样做效果很好,因为不是import * as lib from '../../lib'或者var lib = require('../../lib') import * as lib from 'lib' ,我可以import * as lib from 'lib' 。 Typescript编译/加载lib问题,但VS […]