Qua*_*ive 0 node.js npm visual-studio-code
我在 Windows 10 上使用 Visual Studio Code 1.13.0。我的 中
具有以下构建脚本package.json:
{
//omitted other props
"scripts": {
"build": "webpack"
}
}
Run Code Online (Sandbox Code Playgroud)
我已经安装了webpack ,所以npm install --global webpack它是全局安装的。
这webpack.config.js与我的问题无关。
当我npm run build在终端中运行时,一切正常。但是,当我运行 Visual Code Tasks: Run Build Task(ctrl+shift+b或ctrl+shift+p > Run Build Task)时,我会在输出窗口中收到以下消息:
“npm run build”不被识别为内部或外部命令、可操作程序或批处理文件。
为什么?(使用npm版本:3.10.10)
您应该创建tasks.json 文件并使用 npm 任务运行程序指定构建任务,如ctrl+shift+p > 配置任务运行程序所述。在你的情况下,task.json 文件应该看起来像这样
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
{
"isBuildCommand": true,
"taskName": "build",
"args": ["run", "build"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4966 次 |
| 最近记录: |