node-gyp build error windows x64: "fatal error LNK1181: cannot open input file 'kernel32.lib'" - windows-7-x64

Here's what I've done so far on my x64 OS:
Installed Python (v2.7 --specifically 2.7.6) and added it to the system path (C:\Python27)
Installed MS VS C++ 2010 Express Version (I already had VS 2012 but without the C++ component)
Installed the compiler update for Windows SDK 7.1
Successfully executed node-gyp configure (from my add-on directory under nodejs\node_modules where binding.gyp is located)
ran node-gyp build (as administrator)** This is what crashed, leaving me with:
this error:
C:\Program Files\nodejs\node_modules\msnodesql>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp#0.12.2
gyp info using node#0.10.25 | win32 | x64
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
LINK : fatal error LNK1181: cannot open input file 'kernel32.lib' [C:\Program Files\nodejs\node_modules\msnodesql\build\sqlserver.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\RNelson\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\RNelson\\AppData\\Roaming\\npm\\node_modules\\node- gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\msnodesql
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
Any ideas as to what is going on?

I had a similar problem. I found that this switch helped me
--msvs_version=2012
so for example
npm install --msvs_version=2012 <package>

npm config set msvs_version 2013 --global worked for me as I use VS node tools and you dont need to specify msvs_version each time you do an npm install.
I had an issue whereby npm's config (c:\Users\username\ .npmrc) has an entry msvs_version=2012 which was out of date.

After spending a while to get this to work (for me accepted answer didn't work, for me it's just half solution) i did following:
Sadly, you must have visual studio (i installed express edition 2013
for DESKTOP)
Installed python 2.7.3 (you don't have to set any environment
variables)
Run cmd as administrator and go to you project root (where is you
package.json file)
First run: npm config set python C:\Python27\python.exe
Then: npm install -msvs_version=2013
The trick is in command npm config set python ...path_to_python_exe... which will be provided by npm to dependency which needs python i guess. I don't know why setting python as env variable is not enough.

If all above did not work (my case - Windows10 64bit)
Delete C:\Users\user_name\.node-gyp
Delete %AppData%/npm
Delete %AppData%/npm-cache
And install node-gyp again
Following instruction on node-gyp page
I chose Option 1 npm install --global --production windows-build-tools

For installing node-gyp in windows or any other OS
First you may have to download the node-gyp by
$ npm install -g node-gyp-install
Then install by
$ npm install -g node-gyp
you may need to do the above procedure as root/administrartor.

I had this same error now in 2015 when trying to install Keystone and I ran through all you told me but it didn't work on it's own. At the end, I just had to run the command
"C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\SetEnv.CMD" /Release /x64
to set up the environment before running the command. (Don't freak out when it turns your window text green, it's working). So yeah I'd do the installations and set up environment variables in the same way everywhere on the internet suggests but make sure to run the above command before running any other command. It probably won't be useful to you, but hopefully it's useful to someone else. If that still doesn't work, MSVS version 2010 worked for me, so install that version and use the flag -msvs_version=2010 when running the npm command.

For me the solution that worked with VS express was to simply install Visual Studio 2013 Express for desktop (which is the only one that gives you a developer command prompt as of 2013 version). Open developer command prompt (elevated) and run NPM install commands. This did not require any special --msvs_version arguments, it just worked.

I came across this problem myself, and this is how I solved it using Visual Studio 2010:
Install following packages
Python 2.7+
Visual C++ Studio 2010 Express
Windows SDK 7.1 Note: If you get error on installation, maybe this link will help you.
Visual Studio 2010 SP1
Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
Use npm install from the Windows SDK command prompt (you need this because it sets additional environment variables).
Source: node-gyp instructions for VS2010

For me (Windows 7 64bit),
I struggled with this issue for half of a day Finally It worked.
On my way :
At control panel, I deleted all Python, Microsoft Visual Studio, Microsoft Redistributable, and something about I installed to solve this.
Window Update and restart.
Installed Python27, and Visual Studio 2013 with no setting env-val
npm install node-gyp -g
I got an error same thing, but after npm config set msvs_version 2013 --global , It works.

there is an easy to use windows build tools global node package. You could try this.

I was also getting similar issues and here is what worked for me.
Removed Python and Visual Studio
Installed Python 27 and Microsoft Visual Studio with "Desktop development with C++"
Setting the python path npm config set python /path/to/executable/python
npm install node-gyp -g
node-gyp configure --msvs_version=2013

Just had the same problem. Install NVM (Node version manager) and then open your CMD and use NVM install node# followed by the version your dependencies need. If you don't know what version you might need try playing around with different version I reverted my Node back to version 14.15.0 and then used NPM install and everything ran smoothly! Hope this helps!

Install chocolatey in PowerShell with administrator permissions:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Install required versions of the Microsoft Build Tools for Visual Studio:
https://community.chocolatey.org/packages?q=visual+studio+tools
In my case:
choco install visualstudio2019buildtools
And install workload:
cinst visualstudio2019-workload-vctools
Worked with node 16.16.0
If used nvm. Reinstall node version. And all will work fine.

Related

Running Meteor settings.json from Windows shell

So, I make a Meteor project that uses my MongoDB and other environment variables. Therefore, I create .sh file and write these down.
MONGO_URL="mongodb:<MY DATABASE>" meteor --settings settings.json
However, Meteor cannot realize the current OS is Windows, so it keeps trying to look for meteor modules using Linux's path. Here is the error log.
Runing Meteor with configured db instance in Windows
/mnt/c/Users/mq003/AppData/Local/.meteor/packages/meteor-tool/2.2.0/mt-os.windows.x86_64/meteor: line 137: /mnt/c/Users/mq003/AppData/Local/.meteor/packages/meteor-tool/2.2.0/mt-os.windows.x86_64/dev_bundle/bin/node: No such file or directory
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\Windows\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! simple-todos-react# w-start: `cd build\bin && bash w-run.sh`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the simple-todos-react# w-start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\mq003\AppData\Roaming\npm-cache\_logs\2022-12-06T17_29_40_599Z-debug.log
Does anybody know how to do this in Windows? Thank you in advance.
An easy way to address this is to use crossenv https://www.npmjs.com/package/cross-env
cross-env makes it so you can have a single command without worrying about setting or using the environment variable properly for the platform. Just set it like you would if it's running on a POSIX system, and cross-env will take care of setting it properly.
That way if you have team members using Macs and Windows, it's the same commands, and if you get an upgrade to a Mac yourself, it's seamless.
From what I see you have is likely with your PATH variable.
The error explicitly states it can find the Node.js in you executable directory.
Check to see if any of these identifies the problem. Or I could try to further debug .

Azure DevOps Pipeline NPM install task fails with node-gyp build error

I am trying to build an Azure Pipeline in Azure DevOps. The problem is that when a pipeline ran, an error occurred in an npm build task. Could it be that there are some outdated packages in package.json? Or could it be that npm is outdated?
See Step 4 in a tutorial where a pipeline started to run:
https://learn.microsoft.com/en-us/learn/modules/create-a-build-pipeline/6-create-the-pipeline
Screenshot of build tasks in a pipeline:
Raw Log:
2021-12-03T00:13:53.4119601Z ##[section]Starting: Run npm install
2021-12-03T00:13:53.4130006Z ==============================================================================
2021-12-03T00:13:53.4130664Z Task : npm
2021-12-03T00:13:53.4144256Z Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
2021-12-03T00:13:53.4145177Z Version : 1.187.0
2021-12-03T00:13:53.4145620Z Author : Microsoft Corporation
2021-12-03T00:13:53.4146127Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/npm
2021-12-03T00:13:53.4146868Z ==============================================================================
2021-12-03T00:13:54.7198556Z [command]/usr/local/bin/npm --version
2021-12-03T00:13:55.4151672Z 8.1.0
2021-12-03T00:13:56.0808980Z [command]/usr/local/bin/npm config list
2021-12-03T00:13:56.3808693Z ; "env" config from environment
2021-12-03T00:13:56.3811792Z
2021-12-03T00:13:56.3813271Z userconfig = "/home/vsts/work/1/npm/13.npmrc"
2021-12-03T00:13:56.3814393Z
2021-12-03T00:13:56.3815603Z ; node bin location = /usr/local/bin/node
2021-12-03T00:13:56.3816682Z ; cwd = /home/vsts/work/1/s
2021-12-03T00:13:56.3817732Z ; HOME = /home/vsts
2021-12-03T00:13:56.3819465Z ; Run `npm config ls -l` to show all defaults.
2021-12-03T00:13:56.3822946Z [command]/usr/local/bin/npm install
2021-12-03T00:16:21.9362133Z npm WARN old lockfile
2021-12-03T00:16:21.9365129Z npm WARN old lockfile The package-lock.json file was created with an old version of npm,
2021-12-03T00:16:21.9369471Z npm WARN old lockfile so supplemental metadata must be fetched from the registry.
2021-12-03T00:16:21.9370832Z npm WARN old lockfile
2021-12-03T00:16:21.9372351Z npm WARN old lockfile This is a one-time fix-up, please be patient...
2021-12-03T00:16:21.9373414Z npm WARN old lockfile
2021-12-03T00:16:21.9375186Z npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
'''
'''
2021-12-03T00:16:22.4541247Z 2732 error | ^
2021-12-03T00:16:22.4542220Z 2732 error /home/vsts/.node-gyp/16.13.0/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
2021-12-03T00:16:22.4543014Z 2732 error 855 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
2021-12-03T00:16:22.4543629Z 2732 error | ^~~~~~~~~~~~~
2021-12-03T00:16:22.4544459Z 2732 error ../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
2021-12-03T00:16:22.4545125Z 2732 error 358 | NODE_MODULE(binding, RegisterModule);
2021-12-03T00:16:22.4545958Z 2732 error | ^~~~~~~~~~~
2021-12-03T00:16:22.4546611Z 2732 error make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
2021-12-03T00:16:22.4547249Z 2732 error gyp ERR! build error
2021-12-03T00:16:22.4547826Z 2732 error gyp ERR! stack Error: `make` failed with exit code: 2
2021-12-03T00:16:22.4548944Z 2732 error gyp ERR! stack at ChildProcess.onExit (/home/vsts/work/1/s/node_modules/node-gyp/lib/build.js:262:23)
2021-12-03T00:16:22.4550047Z 2732 error gyp ERR! stack at ChildProcess.emit (node:events:390:28)
2021-12-03T00:16:22.4550822Z 2732 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
2021-12-03T00:16:22.4551766Z 2732 error gyp ERR! System Linux 5.11.0-1021-azure
2021-12-03T00:16:22.4552997Z 2732 error gyp ERR! command "/usr/local/bin/node" "/home/vsts/work/1/s/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
2021-12-03T00:16:22.4554136Z 2732 error gyp ERR! cwd /home/vsts/work/1/s/node_modules/node-sass
2021-12-03T00:16:22.4554904Z 2732 error gyp ERR! node -v v16.13.0
2021-12-03T00:16:22.4555635Z 2732 error gyp ERR! node-gyp -v v3.8.0
2021-12-03T00:16:22.4556152Z 2732 error gyp ERR! not ok
2021-12-03T00:16:22.4556664Z 2732 error Build failed with error code: 1
2021-12-03T00:16:22.4557176Z 2733 verbose exit 1
2021-12-03T00:16:22.4557451Z
2021-12-03T00:16:22.4593929Z ##[error]Error: Npm failed with return code: 1
2021-12-03T00:16:22.4611672Z ##[section]Finishing: Run npm install
Why did the error occur in this task?
Microsoft updated their VMs around the 3rd December.
In this change the default node version has changed from 14.x to 16.x.
We found this exact issue when running on node 16.
This won't be a Long term fix - As you'll need to work out why your build doesn't work on Node 16, but in the short term you can add a command which tells the build agent to use version 14 of node.
Presuming you are using the modern YAML build pipelines, try adding the following as the first step in your YAML pipeline:
- task: NodeTool#0
inputs:
versionSpec: '14.x'
This should solve any node 16 issues.
If you use Classic pipelines there may be a way of including this step as it is Microsoft provided, but I'm not sure as I don't use Classic mode.
Note:
If you've run npm version 8 (which comes with node 16) it will probably have upgraded your package-lock.json file to the newer version 2 schema.
This updated package-lock.json won't work with version 14, you'll need to revert the file back to version 1 (which if you don't have an old version in source control can be done by just deleting package-lock and running npm install).
You just need to update your packagelock file with the following actions:
Update your node version from 14 to 16 by installing the 16.13.1 LTS version on the node js website: https://nodejs.org/
Update your version of npm with the command:
npm install -g npm#latest
Update your packagelock.json with the command:
npm install
Push your brand new packagelock.json file to azure then launch again your CI
=> it should be OK ^^
For Classic pipelines users, add task "Node.js tool installer" before your npm install. Node.js tool installer makes it possible to specify node version.
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/node-js?view=azure-devops

Unable to publish Loopback application to IBM Cloud using API designer

#ibm -
I'm getting following error while trying to publish loopback application on IBM Cloud using API Designer portal. Please help me understand why is it looking into Temp folder to publish the application and how I can bypass that. I keep getting resource busy or locked issue with apiconnect toolkit.
Here's the node, npm and apiconnect toolkit version I'm using currently. Please let me know if you need any additional details.
node - v8.9.4
npm - v5.6.0
apiconnect - v5.0.8.2 (apiconnect: v2.7.111)
Error publishing runtime: Command failed: npm prune --production npm
ERR! path
C:\Users\SUNNY~1.GOE\AppData\Local\Temp\0.6717806509437265-1517290270545\project\node_modules\cryptiles\node_modules\boom\package.json.1443453620
npm ERR! code EBUSY npm ERR! errno -4082 npm ERR! syscall rename npm
ERR! EBUSY: resource busy or locked, rename
'C:\Users\SUNNY~1.GOE\AppData\Local\Temp\0.6717806509437265-1517290270545\project\node_modules\cryptiles\node_modules\boom\package.json.1443453620'
-> 'C:\Users\SUNNY~1.GOE\AppData\Local\Temp\0.6717806509437265-1517290270545\project\node_modules\cryptiles\node_modules\boom\package.json'
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Sunny\npm-cache_logs\2018-01-30T05_31_21_546Z-debug.log Error ID:
a055ee2d-8232-459b-bf62-f4340837a61b
As a simple step, first run this command from cli
apic stop all
and try the publishing loopbaclk application to IBM Bluemix.
In case, this does not resolve the issue, then the problem may be due to permission issues during the installation of APIC toolkit. Uninstall the toolkit do a fresh install of toolkit using '--unsafe-perm' option with the install command to overrides the permisson issues Here is the example
sudo npm install --unsafe-perm -g apiconnect
Try the publish with the new instance of API Connect and see if it resolves the issue.

Can't install Ionic

I can't install ionic on window. I see this error message.
npm ERR! tar.unpack untar error C:\Users\EUNOVA~2\AppData\Local\Temp\npm-4944-a5
4758ba\registry.npmjs.org\cordova-js-\cordova-js-4.0.0.tgz
npm ERR! tar.unpack untar error C:\Users\EUNOVA~2\AppData\Local\Temp\npm-4944-a5
4758ba\registry.npmjs.org\npm-\npm-1.3.4.tgz
How can I fix it?
Solution worked for me
Follow the steps
Install all necessary dependencies.
http://ionicframework.com/docs/guide/installation.html
Uninstall node.js from PC if already installed
Restart PC
Download and Install node.js (MSI Installer) from http://nodejs.org/dist/v0.10.38/ for x86 or http://nodejs.org/dist/v0.10.38/x64/ for x64
Right-click Command prompt, and then click Run as administrator.
Install Cordova using the command: npm install -g cordova
Finally install Ionic Framework using the command: npm install -g ionic
Reinstall node.js http://nodejs.org/dist/v0.12.7/ for x86 or http://nodejs.org/dist/v0.12.7/x64/ for x64
Done!

kafka-node npm install failing on windows 7

I am new to apache kafka and trying to install their node client which is failing with the following message-
gyp ERR! stack Error: Python executable "python" is v3.4.1, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
There's an optional dependency called snappy that requires compilation. This dependency has been made optional since kafka-node v0.3.3 and above so you can ignore any errors generated from npm install.