在Visual Studio中创建Node.js和React应用程序时,构建脚本不会运行



我按照分步指南配置Visual Studio 2019,以便开发Node.js-React应用程序。 指南在这里: https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-nodejs-with-react-and-jsx?view=vs-2019

简而言之,该指南告诉配置一个 npm 脚本(称为"构建"(,该脚本应在 Visual Studio 编译时触发,以便使用包含 react 组件的 app.tsx 通过打字脚本生成 app-bundle.js。 这必须通过将以下截图的代码添加到package.json来完成

"scripts": {
"build": "webpack-cli app.tsx --config webpack-config.js" 
}

但是它不起作用,因为当我在app.tsx中更改某些内容并运行Visual Studio Debbugger时,网页根本不会更改。

如果我使用 nuget 包控制台运行以下命令

npm run-script build

那么它工作正常!

那么,这是一个VS2019错误,还是我错过了一些技巧?

非常感谢您的帮助

我也有和你类似的问题。 我通过Visual Studio 2017,2019的这个未记录的功能解决了这个问题:

BY manual editing, 
You can add the following post-build event to package.json
"-vs-binding": { "AfterBuild": [ "build" ] }
by GUI, 
in task runner explorer window, 
select "build" task and let popup context menu open using right-mouse-button,
select bindings -> After build (make its preceding check box on)
this will add "-vs-binding" property to your package.json
Either one is okay. This  works on vs 2017 and may works on vs 2019 either.
VS2017,2019 nodejs project build process seems 
not to actually call my "build" script at all.
we should specify the "build" script as post-build event 
for vs default nodejs build action.
It seems weired. I hope Microsoft solve this fault using  patches.

任务运行程序资源管理器捕获映像

最新更新