Tag: visual studio code

VSCode编辑器 – 更改文件时重新启动NodeJs服务器

我正在使用Visual Studio Code作为NodeJS项目的编辑器。 目前我需要手动重新启动服务器,当我更改我的项目中的文件。 VSCode中是否有任何插件或configuration更改,当我在文件中进行更改时,可以自动重新启动NodeJS服务器。

如何在VSCode中将环境variables添加到launch.json中

在node.js项目中使用新的VSCode编辑器。 我正在尝试通过编辑launch.json文件来configuration我的“启动”configuration文件进行debugging。 我需要设置一个连接string作为一个环境variables。 根据launch.json文件中的注释: // Environment variables passed to the program. "env": { } 我曾尝试添加我的环境variables,如下所示: "env": { "CONNECTION_STRING": "Data Source=server;Initial Catalog=catalog;User ID=uid;Password=pwd;MultipleActiveResultSets=true" } 这会导致错误,当我尝试启动我的应用程序; “OpenDebug进程意外终止”。 我还没有find任何可以解释问题的日志文件等。 我知道这个应用程序工作正常,当我设置环境variables,并从标准的命令提示符启动我的应用程序。 如果我在launch.json文件中注释掉我的variables,该应用程序也可以正常运行; 我只是无法连接到数据库。 我假设我在launch.json文件中使用了错误的格式,但我还没有find任何方法来使这个工作。 有任何想法吗?

在Visual Studio代码中运行babel-node

通常通过命令行启动,我可以input: babel-node server.js 当我尝试设置这个断点,以及在Visual Studio代码中不工作时,我收到: /Users/me/proj/node_modules/babel-cli/lib/babel-node.js –debug-brk=31893 –nolazy server.js /Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 1: /Applications: is a directory /Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 3: /Applications: is a directory /Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 4: Dockerfile: command not found /Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: syntax error near unexpected token `(' /Users/me/proj/node_modules/babel-cli/lib/babel-node.js: line 5: ` * when found, before invoking the "real" _babel-node(1) executable.' 我猜测它与可执行文件被从该目录调用,而不是从server.js文件相同的目录 – 但我真的不知道。 […]

如何debugging从Visual Studio代码中的Grunt运行茉莉花testing?

我的unit testing是通过Grunt使用Karma / Jasmine运行的。 当我跑步 grunt test testing从命令行执行。 在Visual Studio代码中打开项目时,可以使用“ Tasks: Run Test Task相同的命令。 VSCode使用test参数执行Grunt并显示输出。 在这种情况下,如何debugging由VSCode运行的testing用例? 当我按下F5时 , launch.json模板文件被打开。 我需要提供什么program , args等来启动/debugging通过grunt test运行相同的grunt test ? 我已经尝试了以下内容: program : /usr/local/bin/grunt args : ["test"] 这成功地启动了Grunt进程并且执行了testing,但是它并不停止在我的testing代码的断点处。 除此之外,它会在几秒钟后closures(或崩溃)整个VSCode进程。 不知道这是VSCode中的错误还是上述运行configuration的结果。

在VSCode导出函数时:“个别声明必须全部导出或全部本地”

我最近升级到Visual Studio Code 0.5.0和一些新的错误,出现以前没有。 我有一堆在本地声明,然后导出的函数。 但是,自升级以来,hover在每个本地函数名称上都会产生错误。合并声明中的单个声明functionName必须全部导出或全部为本地。 这是一个导出的本地函数示例。 var testParamsCreatorUpdater = function (lTestParams, creatorID){ lTestParams.creator = creatorID; return lTestParams; }; module.exports.testParamsCreatorUpdater = testParamsCreatorUpdater; 我知道我可以改变这个… module.exports.testParamsCreatorUpdater = function (lTestParams, creatorID){ lTestParams.creator = creatorID; return lTestParams; }; 并prepend module.exports。 给每个testParamsCreatorUpdater()调用。 但为什么第一个片段错了? 据我所知,require()使module.exports对象中的所有东西都可用于任何需要它的东西。

节点subprocess执行命令失败,错误代码为1

我正在尝试执行一些使用节点jssubprocess和获取错误的行。 以下是我的代码: let cmd : string = "code " + PROJECTS[value]; exec(cmd, function callback(error, stdout, stderr) { console.log("started console app"); }); 错误: cmd:"C:\WINDOWS\system32\cmd.exe /s /c "code c:\Users\shana\Dropbox\code-settings-syn… (length: 82)" code:1 killed:false message:"Command failed: C:\WINDOWS\system32\cmd.exe /s /c "code c:\Users\shana\Dropbox\c… (length: 99)" signal:null stack:undefined 错误JSON的细节。 Full CMD : "C:\WINDOWS\system32\cmd.exe /s /c "code c:\Users\shana\Dropbox\code-settings-sync"" Full message : "Command […]

vscodedebuggingES6应用程序

我有VSCode 0.5.0。 我将compilerOptions标志设置为“ES6”,编辑器开始认识到我的ES6代码是正确的。 我已经安装了babel。 我的摩卡testing使用babel编译器,我的testing通过。 当我用babel-node启动它时,我的应用程序从命令行运行,没有任何问题。 当我从VSCode中debugging应用程序时,它将在没有ES6支持的情况下启动,并且应用程序因ES6语法问题而失败。 有没有debugging设置,我错过了打开?

Visual Studio Code Intellisense不适用于Javascript

我在Windows和Mac上使用Visual Studio代码(VSC)0.10.11。 为了这个问题的目的,我有这个小的JavaScript代码片段: 'use strict'; const os = require('os'); console.log(os.homedir()); 我遵循Visual Studio代码( Blog entry和Pluralsight Visual Studio Code JavaScript Intellisense – 对于那些有账户的人)的John Papa,因此我希望当types可用时,VSC提供了Intellisense和Quick fix选项。 在上面的VSC识别console和log() (我使用hoover,但它与Intellisense相同log()片段: 但不是os和homedir() : 但是所有4种types都可以在typings/main/ambient/node/index.d.ts 。 我知道不同的是在os的情况下的require ,但是在John Papa的video课程中,VSC还为所需的模块提供了IntelliSense。 不同的是,约翰爸爸使用tsd而我使用tsd 。 所以我的问题是 我怎样才能启用Intellisense所有已知的types? 我需要做什么VSC为我提供快速修复(缺lesstypes的模块下的绿线)?

JSHint是否支持节点7(asynchronous/等待)?

我正在使用JSHint的JavaScript项目(与Visual Studio代码)。 而在这个项目中,我使用async / await,哪个JSHint突出显示为错误。 我试图设置jshint,但它似乎是“esversion”的最大版本是6。 jshint支持asynchronous/等待吗? 如果有,如何打开? 如果没有,是否有任何解决方法?

可以将Visual Studio Codeconfiguration为使用nodemon启动

我已经在我的系统中安装了nodemon作为全局包。 它在我在cmd中执行nodemon时nodemon 。 但是当我用这个launch.json文件使用vscode时,vscode抛出这个exception: 请求启动:运行时可执行文件XXX \ XXX \ XXX \ XXX \ nodemon不存在 launch.json是: { "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "node", "request": "launch", "program": "app.js", "stopOnEntry": false, "args": [], "cwd": ".", "runtimeExecutable": nodemon, "runtimeArgs": [ "–nolazy" ], "env": { "NODE_ENV": "development" }, "externalConsole": false, "preLaunchTask": "", "sourceMaps": false, "outDir": null }, { […]