Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

@newrelic/native-metrics does not install on Windows 10 from corrupt vcxproj

bug

#1

I understand that there are previous topics like this, but they don’t seem to align with the issues i’m having.

When attempting to install newrelic, it is saying that there is a corrupt file. I have already attempted clearing the npm cache, as well as trying this in a completely blank project.

I normally use yarn as a package manager instead of npm, but npm produced the same result with cleaner logging so i’ve posted it below.

When this failure occurs, yarn does not save dependencies though, so it stops me from upgrading other dependencies due to this failure. It would be good to get assistance, or have the native-metrics module updated to fix the corrupted file.

OS: Windows 10.0.16299
Node: 8.9.4
NPM: 5.6.0
Yarn: 1.5.1
Python: 2.7.14
Node-gyp: 3.6.2

PS C:\git\test> npm install newrelic

@newrelic/native-metrics@2.2.0 install C:\git\test\node_modules@newrelic\native-metrics
node ./lib/pre-build.js install native_metrics

C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js clean configure
C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build -j 2 /t:native_metrics
native_metrics.cpp
GCBinder.cpp
LoopChecker.cpp
RUsageMeter.cpp
win_delay_load_hook.cc
C:\Users\davidhou.node-gyp\8.9.4\x64\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x39BF92
[C:\git\test\node_modules@newrelic\native-metrics\build\native_metrics.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” “build” “-j” “2” “/t:native_metrics”
gyp ERR! cwd C:\git\test\node_modules@newrelic\native-metrics
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Error: Failed to execute install: Error: Failed to install module: Error: Failed to execute C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build -j 2 /t:native_metrics: code 1; Error: Failed to download https://download.newrelic.com/nodejs_agent/builds/_newrelic_native_metrics-2_2_0-native_metrics-57-win32-x64.gz: code 404
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @newrelic/native-metrics@2.2.0 (node_modules@newrelic\native-metrics):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @newrelic/native-metrics@2.2.0 install: node ./lib/pre-build.js install native_metrics
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

  • newrelic@3.0.0
    added 20 packages in 53.773s

Npm install newrelic
#2

@TTL_DHouweling,

Thanks for all the information. I’ve been looking into this and haven’t been able to determine what the problem might be yet. I want to collect additional information, so I’m going to pull this into an internal support ticket. You should get a message soon.

Best regards,
Jon


#3

Hi,

I am getting a similar error, is there any solution for it?


#4

@AlexJosh,

Unfortunately we were unable to pinpoint the exact reason for this error. From testing on our end, we could not reproduce the error (LINK1107). This Windows error indicates that the system was building the binary incorrectly. This part of the build is outside of the Node Agent, as we simply invoke whichever node-gyp is installed on the system. I would encourage you to check you to double check you have all the proper tools installed:

npm install --global --production windows-build-tools
npm install --global node-gyp

Also, ensure your version of VS Code is up to date.

I have also filed a feature request for prebuilt binaries to be available for Windows. The way the agent tries to install the native metrics module is by first trying to build it locally, and then it will just try and download a pre-built binary from our downloads site. However, we currently only have these binaries for Linux and Mac.

Best regards,
J


#5

A post was split to a new topic: Feature Idea: Node/Azure App


#6

Did someone managed to figure it out?
I’m stuck with this issue and can’t install newrelic on my nodejs repo


#7

I think i sorted it finally… Try the following:

Please report back here if it worked for you.


#8

Thanks for posting your solution back here @TTL_DHouweling - Hopefully this is helpful for other users :smiley:


#9

Can we get the solution marked please?


#10

Getting the same issue I noticed also that the failure indicates a 404:

Error: Failed to execute install: Error: Failed to install module: Error: Failed to execute C:\Program Files\nodejs\node.exe C:\Users\XXXXXXX\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build -j 4 /t:native_metrics: code 1; Error: Failed to download https://download.newrelic.com/nodejs_agent/builds/_newrelic_native_metrics-2_4_0-native_metrics-57-win32-x64.gz: code 404

Sure enough that file doesn’t exist in https://download.newrelic.com/nodejs_agent/builds/


#11

Hi again, @fcha! I’m not clear from your experience if you have tried the solution that has seemed to work for others in your similar situation? (see above snippet, also linked here)

If you did try it and are still unable to reach a resolution, please leet us know and we can help you further troubleshoot. Thanks!


#12

I did and still get the same error. Another post I found seemed to have the same issue and it seems like the file just doesn’t exist but was later uploaded?


#13

Tried it, still the same error:


#14

Encountered the same problem as well and the proposed solution did not work for me.
This was a nightmare to fix; but, I managed to solve it after many hours.

It turned out that the Python 2.7.x installation delivered as part of the Windows Build Tools was corrupt:


(Or it was somehow corrupted when I installed Python 3.7.x)

This can be verified by executing: “python -m site”

I was getting:

ImportError: No module named site

You should get:

$ python -m site
sys.path = [
‘C:\Users\Myself\git\ngp-projects-api’,
‘C:\WINDOWS\SYSTEM32\python27.zip’,
‘C:\Tools\Python27\DLLs’,
‘C:\Tools\Python27\lib’,
‘C:\Tools\Python27\lib\plat-win’,
‘C:\Tools\Python27\lib\lib-tk’,
‘C:\Tools\Python27’,
‘C:\Tools\Python27\lib\site-packages’,
]
USER_BASE: ‘C:\Users\Myself\AppData\Roaming\Python’ (doesn’t exist)
USER_SITE: ‘C:\Users\Myself\AppData\Roaming\Python\Python27\site-packages’ (doesn’t exist)
ENABLE_USER_SITE: True

The site not found error was embedded in the npm install output from newrelic when executing this command:

$ npm install
@newrelic/native-metrics@3.1.0 install C:\Users\MikePawlowski\git\ngp-projects-api\node_modules@newrelic\native-metrics
node ./lib/pre-build.js install native_metrics

You’ll notice that the native_metrics are installed first and if that fails, only then does npm attempt to download the non-existent Windows binary (404)

Note: The other main solution being advocated across forums was to set the Python home and path environment variables. This did not work for me and wasn’t necessary.

export PYTHONHOME=/c/Users/Myself/.windows-build-tools/python27
export PYTHONPATH=/c/Users/Myself/.windows-build-tools/python27/Lib

I fully uninstalled the Python 2.7.x binary that was installed with the Windows Build Tools and manually installed Python 2.7.x binary downloaded from the Python site:
python-2.7.15.amd64.msi
Note: I did not automatically add the new installation to my PATH environment variable.

I manually added it after the fact before executing the npm install again:

export PATH=/c/Tools/Python27:$PATH

Hope this helps.


#15

Such an incredible share, @mpawlow, thank you for sharing! I am sure this will help others in the future—you rock! :blush:


#16

I fixed it just installing python 2.7

choco install python2


#17

I got the same issue as RonenMars, with the same error logs. I’m running Node v10.11.0.

None of the proposed solutions above resolved the issue for me.


#18

This is an update for the @newrelic/native-metrics and Windows installation issue. We recently had a bug fix related to a similar error appearing in the stack trace “\npm\node_modules\node-gyp\bin\node-gyp.js build -j 4 /t:native_metrics”:

If you have an application that could have been affected by this, make sure to update your Node Agent to the latest version. If the changes do not apply, perhaps the package-lock.json is keeping the version from getting updated.


#19

Solution Recap

  1. Install native copy of Python 2.7.x
  2. Install latest version of New Relic agent
  3. Setup the environment to use Python 2.7.x (not Python 3.x)
  4. Run npm install

For those using PowerShell and have both Python 3.x and Python 2.x installed, here is a batch file to setup the Python 2.7.x environment:

echo off

set PYTHONPATH=C:\Tools\Python27\Lib
set PYTHONHOME=C:\Tools\Python27
set PATH=%PYTHONHOME%;%PATH%

python --version
python -m site

echo "PAUSE --------------------->"
pause

#20

Thanks for sharing @mpawlow