Tag: visual studio code

在Nodejs中跨多个文件的Typescript内部模块

我一直在通过StackOverflowpost和多个博客文章,但似乎无法find答案。 我正在使用VS Code,nodejs,typescript和gulp。 当我把我所有的模块控制器代码放入一个这样的文件: <controllers.ts> module Controllers { export class Api { get(controllerName:string):IController { } } } module Controllers { export interface IController { performAction(actionName:string):any; } } module Controllers { export class ControllerBase implements IController { performAction(actionName:string):any { } } } module Controllers { export class UserController extends ControllerBase { } } export = Controllers; […]

关于Node.js v6.0.0上Visual Studio代码(F5)的问题

我有一些与Visual Studio的代码 集群的问题 编辑 如果我按Ctrl + F5它能正常工作,除了F5以外 ,我还需要使用Ctrl来启动命令吗? — 看起来,VS Code Launch命令(F5)启动时,工作人员从不启动。 是否需要对.vscode / launch.json文件进行一些更改才能使群集能够正常工作。 实际代码从Node.js 6 api复制https://nodejs.org/api/cluster.html#cluster_cluster npmtesting Windows命令提示符显示了这一点: Master started Listening port 80 Listening port 80 Listening port 80 Listening port 80 VS代码(F5)debugging控制台显示: node –debug-brk=7601 –nolazy index.js Debugger listening on port 7601 Master started Debugger listening on port 7602 Debugger listening on port […]

在debugging摩卡testing时,Visual Studio代码中的断点没有命中

我正在使用Mocha(和Chai)进行NodeJS模块的unit testing,并且希望在Visual Studio代码中进行debugging。 我在test子文件夹中有一些TypeScript文件,并test了一些testing。 VScode在out目录中生成.js和.map文件(通过tsc watch模式任务)。 我的tsconfig.json文件包含这些设置: { "compilerOptions": { "compileOnSave": true, "module": "commonjs", "target": "es6", "outDir": "out", "removeComments": true, "noImplicitAny": true, "sourceMap": true, "inlineSources": true, "isolatedModules": false, "allowSyntheticDefaultImports": true, "experimentalDecorators": true }, "include": [ "src/**/*", "parser/**/*", "test/**/*" ], "exclude": [ "node_modules", ".vscode-test" ] } 外面包含3个包含3个子目录。 迄今为止都很好。 我可以使用这个命令运行我的testing: mocha –compilers ts:ts-node/register,tsx:ts-node/register 在vscode之外。 然后,我用–debug-brk开关运行了这段代码,并将vscode连接到它。 这有效,但没有断点。 launch.json中的configuration是: […]

__awaiter没有定义

我在VSCode中使用typescript v 1.8.9,nodejs 5.9.1我有我的文件app.ts有这些行 import {XController} from "./XController"; var xContrller=new XController(); xContrller.CallAsyncMethod(some args"); 而XController是一个具有asynchronous方法CallAsyncMethod的类 喜欢这个 public async CallAsyncMethod(url: string) { await this.request.post(url); } 这在JavaScript中翻译为__awaiter(void,…),但它崩溃,说__awaiter没有定义? 任何线索为什么发生这种情况,以及如何解决这个问题。 谢谢

工作区设置权限被拒绝

我正在运行Ubuntu 12.04LTS。 在我的用户标识拥有的文件夹中解压缩Visual Studio代码。 所有vscode文件都属于我的用户标识(用户和组)。 通过apt-get(和npm)安装node,npm,typescript。 Visual Studio代码运行正常,但是文件 – >首选项 – >工作区设置给出了这个错误: 无法创build'vscode / settings.json'(错误:EACCES:权限被拒绝,mkdir'/.vscode')。 任何想法如何解决这个问题? 它在哪里试图做'mkdir'? 谢谢, 鲍勃·威尔卡 更新:Sudo'd mkdir“/.vscode”(字面上在根级别),并chown'drecursion到我的用户和组。 瞧! 现在我可以编辑设置。 那么,有没有办法告诉Visual Studio Code,它不应该试图使用根文件夹?

string枚举的反向映射

我想在打字稿中使用string枚举,但是我看不到支持反转映射。 我有这样的枚举: enum Mode { Silent = "Silent", Normal = "Normal", Deleted = "Deleted" } 我需要像这样使用它: let modeStr: string; let mode: Mode = Mode[modeStr]; 是的,我不知道它在modeStrstring中有什么,我需要它parsing为枚举或在运行时parsing失败,如果该string没有出现在枚举定义。 我怎样才能做到这一点,因为它可以是? 提前致谢

如何find在Node + Typescript + VSCodeasynchronous函数调用缺less的等待?

我们在节点应用程序b / c中部署了错误,我们忘记用“await”作为前缀asynchronous函数调用。 例: const getUsers = async () => db.query('SELECT * from Users'); const testMissingAwait = async () => { const users = getUsers(); // <<< missing await console.log(users.length); }; testMissingAwait(); 有没有一种简单的方法来find缺lessawait关键字的asynchronous函数调用? 否则,编写一个Visual Studio代码扩展会自动标记这些扩展会花多less功夫? (如果有人能指出我的方向,我可以解决问题)。

参数中的–harmony标志似乎不起作用

args参数中的–harmony标志看起来不起作用。 我不能使用胖arraysfunction。 这里是lounch.json一部分 "configurations": [ { // Name of configuration; appears in the launch configuration drop down menu. "name": "Launch app.js", // Type of configuration. Possible values: "node", "mono". "type": "node", // Workspace relative or absolute path to the program. "program": "./app.js", // Automatically stop program after launch. "stopOnEntry": true, // Command line arguments passed […]

Visual Studio代码 – Node.js – 找不到名字'__dirname'

只是为了说明,我不是一个专业的编码员,但是当我发现10年前我在高中就读了“网页devise”之后,我就一直为我的老板build立一个网站。 那时静态网站很好,而且CSS刚刚开始显示它的潜力,但我离题了。 我正在使用Visual Studio Code的Node.js项目,并有一个奇怪的例外。 代码工作正常,但我想这只是好奇心。 无论如何,这是我的代码。 app.js var express = require('express'), app = express(), bodyParser = require('body-parser'), multer = require('multer'), controller = require('./controllers'); //Sets the view engine to jade. app.set('views', __dirname + '/frontend'); app.set('view engine', 'jade'); //sets up the development enviroment if (app.get('env') === 'development') { app.locals.pretty = true; app.use(express.static(__dirname + '/build/public')) var build […]

使用vscodedebuggingnpm脚本的正确方法是什么?

我有一个npm脚本,我正在尝试debugging。 我使用vscode,所以我想我会创build一个debuggingconfiguration,并与debugging器一步。 我的npm脚本看起来是: "scripts": { … "dev": "node tasks/runner.js", } 所以我创build了以下debuggingconfiguration: { "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "runtimeExecutable": "npm", "cwd": "${workspaceRoot}", "runtimeArgs": [ "run", "dev" ], "port": 5858, "stopOnEntry": true } ] } 当我启动它的脚本运行,但Vscode永远不能连接,我得到的错误: 无法通过“传统”协议连接到运行时; 考虑使用“检查员”协议(10000 ms后超时)。 我试图添加一个督察协议: { "type": "node", "request": "attach", "name": "Attach (Inspector Protocol)", "port": […]