简体   繁体   English

NPM Runner可在VS 2017中使用,但不适用于Vs 2019

[英]NPM Runner works in VS 2017 but not in Vs 2019

I have a project that is using npm and webpack for our CSS and JavaScript bundling, which works just fine in VS 2017. 我有一个使用npm和webpack进行CSS和JavaScript捆绑的项目,在VS 2017中工作正常。

However, we are now using VS 2019 and after installing the extensions for both the NPM and Webpack Task Runners to be the same as the VS 2017 installation. 但是,我们现在使用的是VS 2019,并且在安装NPM和Webpack Task Runners的扩展后与VS 2017安装相同。

In VS 2019, I get the following error. 在VS 2019中,出现以下错误。

One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
 - webpack-cli (https://github.com/webpack/webpack-cli)
   The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".

So, I opened VS 2017 with same project and it still operates fine, bundling CSS and JavaScript with no errors. 因此,我以相同的项目打开了VS 2017,它仍然可以正常运行,将CSS和JavaScript捆绑在一起没有任何错误。

This was a known issue in the preview VS 2019 releases, my current versions in 这是VS 2019预览版中的一个已知问题,我当前的版本是

Software versions: - VS 2019 Version 16.2.3 - VS 2017 Version 15.9.15 - NPM Task Runner 1.4.90 (same for both) - Webpack Task Runner 1.5.94 (same for both) 软件版本:-VS 2019版本16.2.3-VS 2017版本15.9.15-NPM Task Runner 1.4.90(两者相同)-Webpack Task Runner 1.5.94(两者相同)

Does anyone know how to fix this, as currently I am having to open VS 2017 just to run the Task Runner? 有谁知道如何解决此问题,因为目前我只需要打开VS 2017才能运行Task Runner?

UPDATE 更新

Interesting side note. 有趣的旁注。 If I open up a command prompt and run 如果我打开命令提示符并运行

npm run build 

from the project folder, it works, so is this just some fault within the task runner? 从项目文件夹中,它可以正常工作,所以这仅仅是任务运行程序中的一些错误吗?

Latest version of Webpack requires you to install Webpack CLI on your own now. 最新版本的Webpack要求您立即自行安装Webpack CLI。

I think somehow, VS 2017 has locked into a specific version of Webpack while VS 2019 has installed latest Webpack due to ^ version flag in your package.json. 我认为以某种方式,由于package.json中的^版本标志,VS 2017已锁定到特定版本的Webpack,而VS 2019已安装了最新的Webpack。

To fix the issue, open up a terminal to the location of package.json and run: 要解决此问题,请在终端上打开package.json的位置,然后运行:

npm install webpack-cli --save-dev

Then try again in VS 2019. 然后在VS 2019中重试。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM