gpt4 book ai didi

javascript - 用于运行 MEANJS 工作流的 Visual Studio Code 配置

转载 作者:搜寻专家 更新时间:2023-11-01 04:15:35 25 4
gpt4 key购买 nike

我刚刚安装了 Visual Studio Code 并且正在尝试运行我的 MEANJS IDE 中的应用程序,VisualStudio 创建了一个 ./settings 文件夹,其中包含一个 launch.json 文件,其中包含运行项目的配置。

我通常使用 MEANJS 工作流程所做的只是在应用程序的根文件夹中键入 grunt 并调用包含所有启动我的应用程序的作业。

我想尝试通过按下按钮播放在 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 示例


您可以使用 Visual Studio Code 设置任何工作流工具并使用 CTRL+SHFT+P,然后使用 RUN 并选择 TASKS。您还可以分别使用 CTRL+SHFT+BCTRL+SHFT-T 设置默认的 BUILDTEST 任务.只要任务运行器 Gulp、Grunt、Cake 或其他设置正确,就可以配置 VSCode。

您可以通过名称在 VSCode 中设置所有 Gulp 或其他任务运行器任务,或者仅设置几个也运行其他子任务的任务。

从 VSCode 0.5.0 开始,任务参数存在问题,需要在 tasks.json 文件中反转它们。更多信息 here

{
"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"
]
},

请注意前两个任务将 isBuildCommandisTestCommand 设置为“true”,这允许使用上述键盘快捷键。从 VSCode 0.5.0 开始,最后一个任务需要有 argumentcommand 名称 reversed 才能工作。看这个link .

使用 VSCode 调试


您可以使用 VSCode 调试器运行 Node.js 应用程序并启动播放 按钮并使用圆形箭头 重新开始。为此,您需要配置 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 运行节点应用


您还可以使用 Gulp 或其他任务运行器来启动和自动重启您的 node.js 应用程序等。我更喜欢 Gulp,因为它是代码而不是配置设置,而且它本质上使用流。

gulp.js 引用了另一个名为 gulp.config.js 的文件,其中包含未显示的各种静态变量和函数,因此在整个 gulpfile.js 中引用了配置。这是要求声明:

//require containing config variables and run
var config = require('./gulp.config.js')();

以下是我在拍摄 Plurasight Course 时使用的 gulpfile.js约翰爸爸教的。在配置中定义了许多任务,包括运行节点服务器应用程序的 Gulp 任务 SERVE-DEV,在 js、css 或 html 更改时自动重启服务器并同步多个浏览器 View ,注入(inject) CSS 和 JS,编译LESS,以及其他任务。

GULP 文件的 GIST 链接


Gulp 文件太复杂,Stack Overflow 标记无法解释,所以我添加了 GistBox Link .

关于javascript - 用于运行 MEANJS 工作流的 Visual Studio Code 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31620566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com