edge-js build failing with nw-gyp - node-webkit

Description
I want to use edge-js with nw.js. And as edge-js is not pure js package , I have to rebuild it with nw-gyp to get it working.
(https://github.com/nwjs/nw.js/wiki/using-node-modules)
Tried to re-build edge-js with nw-gyp, but facing compilation issues. The error snapshot is attached
Followed below 2 links to install nw-gyp
https://github.com/nwjs/nw-gyp#installation
Build edge-js with nw
https://github.com/nwjs/nw.js/wiki/Build-native-modules-with-nw-gyp
Package version
"edge-js": "^15.5.2"
Commands used to build
nw-gyp configure --target=0.42.3
nw-gyp rebuild --target=0.42.3
nw.js v0.42.3
Error Message & Stack Trace
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h(16): error : invalid preprocessing directive [E:\compile_node_modules\node_modules\edge-js\build\edge_nati
veclr.vcxproj]
In file included from ..\src\dotnet\utils.cpp:1:
In file included from ..\src\dotnet/edge.h:22:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h:17:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\gcroot.h:42:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\msclr/gcroot.h(58): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
In file included from ..\src\dotnet\utils.cpp:1:
In file included from ..\src\dotnet/edge.h:22:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h(29): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h(30): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h(31): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h(32): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcclr.h(44): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
In file included from ..\src\dotnet\utils.cpp:1:
..\src\dotnet/edge.h(24): error : invalid preprocessing directive [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
..\src\dotnet/edge.h(25): error : invalid preprocessing directive [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
..\src\dotnet/edge.h(27): error : use of undeclared identifier 'System' [E:\compile_node_modules\node_modules\edge-js\build\edge_nativeclr.vcxproj]
Relevant Information
Environment: Windows_NT 10.0.19041
npm configurations
\edge-js> npm config get
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.13.4 node/v12.14.1 win32 x64"
; userconfig C:\Users\<user>\.npmrc
msvs_version = "2015"
node_gyp = "C:\\Users\\<user>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
python = "python2.7"
; globalconfig C:\Users\<user>\AppData\Roaming\npm\etc\npmrc
node_gyp = "C:\\Users\\<user>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
; builtin config undefined
prefix = "C:\\Users\\<user>\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = E:\compile_node_modules\node_modules\edge-js
; HOME = C:\Users\<user>
; "npm config ls -l" to show all defaults.

It may be related to Python 3. Node-gyp was originally based on Python 2. It has been transitioning to Python 3 for the past few years.
* 2019 - Node-gyp 5.x started adopting Python 3
* 2020 - Node-gyp 6.x started to work with Python 3
* 2020 - Node-gyp 7.x works with Python 3
* 2021 - Node-gyp 8.x removes all Python 2 support, only supports Python 3
Source: Node-gyp changelog
NW-gyp was based on Node-gyp with some tweaks, back when it was using Python 2. It has not been updated to support Python 3. So if you are using newer versions of NW.js, that come with newer versions of Node, and you have newer versions of npm globally installed, it may be trying to use Python 3 stuff with Node-gyp, which doesn't support that. This is all a guess on my part, I know very little about Node-gyp/NW-gyp/Python.
If this hunch is correct then you could try using an older version of NW.js. Node-gyp 5 started Python 3 adoption on 2019-06-13, so the latest node/npm before that would be Node 12.4.0 (2019-06-04) and npm 6.9.0. The version of NW.js that ships with Node 12.4.0 is v0.39.2.
Source: Node.js Previous Releases
Source: NW.js Official versions.json
If you don't have nvm or nvm-windows installed, uninstall Node.js and npm first, so you don't have globally competing versions.
Install nvm or nvm-windows
https://github.com/nvm-sh/nvm
https://github.com/coreybutler/nvm-windows
Use nvm/nvm-windows to install Node.js 12.4.0 (should also install npm 6.9.0)
nvm install 12.4.0 && nvm use 12.4.0
Delete your node_modules
npm install --save-dev nw#0.39.2-sdk
npm install
npm start 🤷‍♀️
That's all I got. Hopefully someone else can help more, or this at least points you in the right direction.

Related

Missing required property 'OutputPath' for project type 'PackageReference'

I'm trying to run the following command thru Jenkins Pipeline
bat 'nuget restore mySolution.sln -MSBuildPath "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"'
but i'm getting error saying
Invalid restore input. Missing required property 'OutputPath' for
project type 'PackageReference'. Input files: C:\Program Files
(x86)\Jenkins\workspace\My Project Build
Pipeline\myProject\myProject.csproj.
I tried
bat label: '', script: '"C:\\Package tools\\nuget.exe" restore "C:\\Program Files (x86)\\Jenkins\\workspace\\My Project Build Pipeline\\myProject\\myProject.csproj" -MSBuildPath "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"' // Restore packages.
I'm expecting all the NuGet packages to get installed as we 'Restore NuGet Packages' in Visual Studio.
Apparently you are using VS 2015 tools (MSBuild 14) and/or an older nuget.exe (< 4.0.0) to work on projects using the PackageReference way of referencing NuGet Packages. Use newer tools (Nuget 4+, VS / Build Tools 2017+) to fix this issue.
I fixed this problem by running the powershell command:
Install-Module VSSetup -Scope CurrentUser

Gulp sass returning Error: python2 not found

This is what I see when I try to install gulp-sass like this:
npm i gulp-sass --save-dev
Running gulp-watch and gulp browser-sync works
TIA
As the error message suggests you probably don't have python installed. The node-sass library compiles the libsass from source. For that it uses node-gyp. To build under windows the readme suggests:
On Windows
Option 1
Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).
Option 2
Install tools and configuration manually:
Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio 2017 Community (using the "Desktop development with C++" workload)
Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7 (or see below for further instructions on specifying the proper Python version and path.)
Launch cmd, npm config set msvs_version 2017
If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.
If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:
node-gyp --python /path/to/python2.7
If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:
npm config set python /path/to/executable/python2.7

React-Native Install Error

ling react-native I get the following error (on windows)
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(31):
error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers
[C:\Projects\JustEatLife\node_modules\react-native\node_modules\ws
\node_modules\bufferutil\build\bufferutil.vcxproj]
I've installed windows sdks, added the C++ tools to my VS 2015 installation, installed android studio, java etc.
Is there any way to resolve this?
I got same problem, and for me the answer was to update node-gyb from version 3.3.1 to 3.4.0 in npm.
For instructions how to do it, see:
npm install fails with error C2373 with vs2015 update 3
If npm i fails, try npm install node-gyp after you have updated version number in packages.json

Installing scss-lint with npm without Python

I'm trying to get gulp-scss-lint to work on my machine, but having trouble doing so.
Context
I have a feeling specific versions and environment settings may be important to my issue, so let me list my specific context:
Windows Server 2012 R2 Standard
NPM 2.14.7
Node 4.2.2
Gulp 3.9.0 installed -g
Running from Powershell 4.0
Repro
Here's a repro of my problem:
mkdir gulpscsslint and cd gulpscsslint
npm init with all default answers
npm install gulp --save-dev
npm install gulp-scss-lint --save-dev
new-item -itemtype file gulpfile.js and enter:
var gulp = require('gulp'), lint = require('gulp-scss-lint');
gulp.task('default', [], function() {
return gulp.src('*.scss').pipe(lint());
});
new-item -itemtype file styles.scss
gulp
Result:
[08:48:50] Using gulpfile ~\experiments\gulpscsslint\gulpfile.js
[08:48:50] Starting 'default'...
[08:48:50] 'default' errored after 32 ms
[08:48:50] Error in plugin 'gulp-scss-lint'
Message:
Error code 1
Error: Command failed: C:\Windows\system32\cmd.exe /s /c "scss-lint 'styles.scss' --format=JSON"
'scss-lint' is not recognized as an internal or external command,
operable program or batch file.
Expected result was obviously actual output from the linter.
So then I continued:
npm install scss-lint --save-dev
But it fails with failNoPython, with this snippet from the output:
Can not download file from https://raw.githubusercontent.com/sass/node-sass-binaries/v2.1.1/win32-x64-node-4.2/binding.node
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable
Question
Is it really a hard requirement to have Python to install this Node package? Or can it somehow be installed without installing Python?
As a footnote, now that I've fully written this question I realize this might be more something of a Github issue, but if so I might need some help (learning how to) find(ing) out what package or tool is giving me trouble (gulp-scss-lint? scss-lint? npm? node-sass or some other underlying package?).
You can manually install the package by cloning or downloading it directly from it's github repository and placing it into your targeted location.
Note:
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. Link
This package requires Python to work. Hundreds of packages, including npm and npminstall, rely on node-gyp to compile. On windows, a person can install the package windows-build-tools, which includes python, to use node-gyp.

Issue installing bower on windows

I'm using Windows 7 64bit and I install Bower with
npm install -g bower
It seems to install correctly.
npm http GET https://registry.npmjs.org/amdefine
npm http 304 https://registry.npmjs.org/amdefine
C:\Program Files (x86)\Git\local\bower -> C:\Program Files (x86)\Git\local\node_
modules\bower\bin\bower
bower#1.3.3 C:\Program Files (x86)\Git\local\node_modules\bower
...
But bower is not working:
$bower
sh.exe": bower: command not found
$bower -v
sh.exe": bower: command not found
What could be wrong?
Same problem but for me I had to add the Path Environment Variable that pointed to the AppData/Roming/ folder. I have no idea why node.js would install npm in the Roming folder. If I didn't have hidden folders turned on we never would have found it.
C:\Users\me\AppData\Roaming\npm;
Then npm works from Node.js command prompt, and bower works from GitBash.
Check if C:\Program Files (x86)\Git\local is added to your Path Environment Variable.
Check your version of node, I was running on v0.10.15 then updated to v0.10.35 and that fixed the issue for me.