Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

node.js - Error MSB4062: The "SetEnv" task could not be loaded from the assembly

So I am trying to install a Node package called better-sqlite-pool, however I am stuck with an error which I can't seem to resolve. Whenever I run npm i better-sqlite-pool, I get the following error:

C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140Microsoft.Cpp.Current.targets(64,5): error MSB4062: The "SetEnv"
 task could not be loaded from the assembly C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140Microsoft.Build.CppT
asks.Common.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, Pu
blicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the
<UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contain
s a public class that implements Microsoft.Build.Framework.ITask. [D:FilesScrimsBot
ode_modulesintegeruildintege
r.vcxproj]

I have done extensive research on this, and have tried pretty much all of the suggested fixes to no success.

The first error I received I managed to fix by adding an environment variable of VCTargetsPath and setting it to C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140. The error I received before doing this was the following:

The imported project "D:Microsoft.
Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exist
s on disk.

Another thing I tried was installing the build tools using the npm install -g --production windows-build-tools command however that made no difference.

It is probably worth noting that I have Visual Studio 2017 Enterprise installed with the VC++ 2015.3 v14.00 (v140) toolset for desktop component installed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have a rather similar issue, and got stock at the same point. I found two possible solutions over here:

  • install Visual Studio 2015 as well
  • create .config file in the same dir as your exe (if you don't have it already) containing binding redirection of msbuild assemblies

The first option works for me:

  • use an administrator prompt from the current user, don't elevate from a limited user, the paths will be a mess if you do that
  • npm install --global --production --vs2015 windows-build-tools
  • npm install --global --production windows-build-tools (this one gets stuck during the installation, ctrl-c to end it)
  • npm install --global --production windows-build-tools (yes, the same command again to finish the configuration)
  • npm config set msvs_version 2015 --global

Since I'm not a real programmer I wouldn't know where to begin for the latter option.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...