Visual Studio Code配置以运行MEANJS工作流
Visual Studio Code configuration to run MEANJS workflow
我刚刚安装了Visual Studio Code,我试图在IDE中运行我的MEANJS应用程序,VisualStudio创建了一个启动的。/settings文件夹。Json文件,其中包含运行项目的配置。
我通常使用MEANJS工作流只是在应用程序的根文件夹中输入grunt,并命令调用gruntfile.js,其中包含启动应用程序的所有作业。
我想尝试在Visual Studio Code中通过按下按钮播放来实现相同的功能,并运行grunt任务,但我不知道从哪里开始。
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Launch Project",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "gruntfile.js",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
"runtimeArgs": [],
// Environment variables passed to the program.
"env": { },
// Use JavaScript source maps (if they exist).
"sourceMaps": false,
// If JavaScript source maps are enabled, the generated code is expected in this directory.
"outDir": null
},
{
"name": "Attach",
"type": "node",
// TCP/IP address. Default is "localhost".
"address": "localhost",
// Port to attach to.
"port": 3000,
"sourceMaps": false
}
]
}
建议吗?
VSCode EXAMPLE
你可以用Visual Studio Code设置任何工作流工具,先用CTRL+SHFT+P
,然后用RUN
,然后选择TASKS
。您还可以分别使用CTRL+SHFT+B
和CTRL+SHFT-T
设置默认的BUILD
和TEST
任务。只要任务运行器Gulp, Grunt, Cake或其他设置正确,VSCode就可以配置。
你可以在VSCode中设置所有的Gulp或其他任务运行器任务,或者只设置几个也运行其他子任务的任务。
从VSCode 0.5.0开始,任务参数有一个问题,需要在任务中反转它们。json文件。更多信息在这里
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "vet",
"isBuildCommand": true,
"isTestCommand": false,
"showOutput": "always",
"args": [],
"problemMatcher": [
"$jshint",
"$jshint-stylish"
]
},
{
"taskName": "vet-es",
"isBuildCommand": false,
"isTestCommand": true,
"showOutput": "always",
"args": [],
"problemMatcher": [
"$eslint-compact",
"$eslint-stylish"
]
},
{
"taskName": "--verbose",
"isBuildCommand": false,
"isTestCommand": false,
"showOutput": "always",
"args": [
"vet"
],
"problemMatcher": [
"$jshint",
"$jshint-stylish"
]
},
注意前两个任务将isBuildCommand
和isTestCommand
设置为"true",这允许上面提到的键盘快捷键。最后一个任务需要有argument
和command
的名称reversed
,作为VSCode 0.5.0,为了工作。请看这个链接。
USING VSCode Debug
你可以将VSCode调试器设置为Run
Node.js应用程序和Start
Play
按钮,用Circular Arrow
重新启动。为此,您需要配置launch.json。如果你只是想启动/重新启动应用程序而不进行调试,那么将stoponentry
设置为false。我通常有两个,一个用于调试,一个用于运行。
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Debug src/server/app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "src/server/app.js",
// Automatically stop program after launch.
"stopOnEntry": true,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
"runtimeArgs": [],
// Environment variables passed to the program.
"env": { },
// Use JavaScript source maps (if they exist).
"sourceMaps": false,
// If JavaScript source maps are enabled, the generated code is expected in this directory.
"outDir": null
},
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run src/server/app.js",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "src/server/app.js",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
"runtimeArgs": [],
// Environment variables passed to the program.
"env": { },
// Use JavaScript source maps (if they exist).
"sourceMaps": false,
// If JavaScript source maps are enabled, the generated code is expected in this directory.
"outDir": null
},
使用GULP运行NODE APP
你也可以使用Gulp或其他任务运行器来启动和自动重启你的node.js应用。我更喜欢Gulp,因为它的代码多于配置设置,而且它本身就使用流。
还有一个名为gulp.config.js的文件,它被gulp.js引用,其中包含了各种静态变量和函数,这些变量和函数没有显示出来,因此在gulpfile.js中引用了config。下面是require语句:
//require containing config variables and run
var config = require('./gulp.config.js')();
下面是我在参加John Papa教授的Plurasight课程时使用的gulpfile.js。在配置中定义了许多任务,包括Gulp任务SERVE-DEV
,它运行节点服务器应用程序,在js, css或html更改时自动重启服务器,同步多个浏览器视图,注入css和js,编译LESS等任务。
GULP文件的GIST链接
Gulp文件太复杂了,Stack Overflow标记无法解释,所以我添加了这个gstbox链接。
在任务。Json文件替换这些设置
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "grunt",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": ["serve"]
}
如果你的grunt文件没有"serve"参数,你可以不使用它。
然而,这将不会运行按下绿色启动按钮。要启动此任务,您需要按
Ctrl + Shift + p
从这里你可以使用任务命令。
可以通过键盘快捷键设置和运行任务。
更新:我没有找到如何在Visual Studio Code中做到这一点,但在WebStorn中,这是一个简单的设置,只需点击几下鼠标。
- 如何使用phaser使html5游戏在移动设备浏览器上运行
- 使用压缩的JavaScript文件(不是运行时压缩)
- Javascript运行php文件,然后下载文件
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- 我已经创建了一个jquery转盘,并使用if条件来运行和停止转盘
- Angularjs代码未在匿名函数中运行
- jquery设置为使用参数运行
- 如何根据时间运行不同的脚本
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 将文本框链接到由按钮运行的javascript公式
- 为什么不是't运行此Javascript的Chrome
- ng应用程序使脚本无限运行
- 如何在运行时在angular 2中加载外部js脚本
- 与运行长作业(javascript,node.js)的第三方API同步的最佳实践
- JavaScript错误:Microsoft JScript运行时错误:应为对象
- 在终端中运行 JavaScript 时(使用 rhino),如何使用 print() 函数在一行中打印
- 如何使用JS/nightwatchjs并行运行多个测试
- 茉莉花宝石-耙茉莉花:ci dons't运行测试
- 我的HTML按钮没有在Javascript中运行
- Visual Studio Code配置以运行MEANJS工作流