Can I run NPM/NodeJS app on Debian running 8 on OpenVZ? - node.js

I want to run rocketchat (a nodejs app) on my Debian 8 VPS. This VPS runs on OpenVZ, so the kernel version is 2.6.32-042stab108.8.
Installing NodeJS as described on nodejs website (their own repo, not the one provided by debian) works without a problem.
However, when i run
npm install
NPM fails to install required packages and prints the following:
npm WARN package.json meteor-dev-bundle#0.0.0 No description
npm WARN package.json meteor-dev-bundle#0.0.0 No repository field.
npm WARN package.json meteor-dev-bundle#0.0.0 No README data
npm WARN package.json meteor-dev-bundle#0.0.0 No license field.
\
> fibers#1.0.5 install /home/rocketchat/rchat/programs/server/node_modules/fibers
> node ./build.js
(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
make: Entering directory '/home/rocketchat/rchat/programs/server/node_modules/fibers/build'
CXX(target) Release/obj.target/fibers/src/fibers.o
../src/fibers.cc: In function 'v8::Handle<v8::Signature> uni::NewSignature(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, int, v8::Handle<v8::FunctionTemplate>*)':
../src/fibers.cc:132:54: error: no matching function for call to 'v8::Signature::New(v8::Isolate*&, v8::Handle<v8::FunctionTemplate>&, int&, v8::Handle<v8::FunctionTemplate>*&)'
return Signature::New(isolate, receiver, argc, argv);
^
../src/fibers.cc:132:54: note: candidate is:
In file included from /home/rocketchat/.node-gyp/4.4.2/include/node/node.h:42:0,
from ../src/coroutine.h:1,
from ../src/fibers.cc:1:
/home/rocketchat/.node-gyp/4.4.2/include/node/v8.h:4675:27: note: static v8::Local<v8::Signature> v8::Signature::New(v8::Isolate*, v8::Local<v8::FunctionTemplate>)
static Local<Signature> New(
^
/home/rocketchat/.node-gyp/4.4.2/include/node/v8.h:4675:27: note: candidate expects 2 arguments, 4 provided
../src/fibers.cc: In function 'void uni::SetResourceConstraints(v8::Isolate*, v8::ResourceConstraints*)':
../src/fibers.cc:140:3: error: 'SetResourceConstraints' is not a member of 'v8'
v8::SetResourceConstraints(isolate, constraints);
^
../src/fibers.cc:140:3: note: suggested alternative:
../src/fibers.cc:139:7: note: 'uni::SetResourceConstraints'
void SetResourceConstraints(Isolate* isolate, ResourceConstraints* constraints) {
^
../src/fibers.cc: In function 'v8::Handle<v8::Signature> uni::NewSignature(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, int, v8::Handle<v8::FunctionTemplate>*)':
../src/fibers.cc:133:2: warning: control reaches end of non-void function [-Wreturn-type]
}
^
fibers.target.mk:97: recipe for target 'Release/obj.target/fibers/src/fibers.o' failed
make: *** [Release/obj.target/fibers/src/fibers.o] Error 1
make: Leaving directory '/home/rocketchat/rchat/programs/server/node_modules/fibers/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-042stab108.8
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /home/rocketchat/rchat/programs/server/node_modules/fibers
gyp ERR! node -v v4.4.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
Build failed
npm ERR! Linux 2.6.32-042stab108.8
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--build-from-source"
npm ERR! node v4.4.2
npm ERR! npm v2.15.0
npm ERR! code ELIFECYCLE
npm ERR! fibers#1.0.5 install: `node ./build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers#1.0.5 install script 'node ./build.js'.
npm ERR! This is most likely a problem with the fibers package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs fibers
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls fibers
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/rocketchat/rchat/programs/server/npm-debug.log
Does it happen because the kernel is too old? It just seems strange that a specific type of virtualization makes nodejs unusable.
Edit: included full npm install output
Edit2: Compiler versions are gcc-4.9, g++-4.9

I figured it out.
First of all, no - the kernel version required by OpenVZ has nothing to do with this.
Here's what happened. The nodeJS app I tried to install (Rocket.Chat) was built with a Meteor framework. Apparently, Meteor only works on NodeJS v0.10.40. Debian 8 repositories only has v4.4.2 and v0.10.29, nodejs website has instructions for v4 and v5.
If you encounter this issue, my advice is to install node v0.10.40 via node version manager. Once it is done, npm install will work as advertised.

Related

canvas node module and Google Cloud Functions

I am trying to create a Google Cloud Function that generates an image from text.
I've used this Canvas node module
(had to install these dependencies on Mac to run it locally)
brew install pkg-config cairo pango libpng jpeg giflib
My package.json looks like this:
"dependencies": {
"canvas": "^1.6.5"
}
While trying to deploy it as a Function to Google cloud I am getting this error (seems like there are missing dependencies on the remote container)
Copying file:///var/folders/rq/jqlbr35d6gg3_bjhwgzdjm3m0000gn/T/tmpsuL8lN/fun.zip [Content-Type=application/zip]...
- [1 files][ 722.0 B/ 722.0 B]
Operation completed over 1 objects/722.0 B.
Waiting for operation to finish...failed.
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Build failed: exit status 1
> canvas#1.6.5 install /workspace/node_modules/canvas
> node-gyp rebuild
./util/has_lib.sh: 31: ./util/has_lib.sh: pkg-config: not found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-78-generic
gyp ERR! command "/nodejs/bin/node" "/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /workspace/node_modules/canvas
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN img#1.0.0 No description
npm WARN img#1.0.0 No repository field.
npm ERR! Linux 4.4.0-78-generic
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "--global-style" "--production" "--fetch-retries=5" "--fetch-retry-factor=2" "--fetch-retry-mintimeout=1000" "install" "/workspace"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! canvas#1.6.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas#1.6.5 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs canvas
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls canvas
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /workspace/npm-debug.log
On Ubuntu 16.04, I was able to clear up a similar problem by following the instructions here to install dependencies: https://www.npmjs.com/package/canvas

Using node module with react native

As mentioned here that,
Any modules that are pure javascript and run within node.js/io.js are perfectly OK to be run in react-native.
I need to resize and crop an image in react native so i was trying the nodejs sharp image processing library and i think it should work with reactnative because its in pure node and working with io things.
But while installing it throws errors:
PS D:\ReactNative\f_sandbox> npm install sharp
> sharp#0.17.3 install D:\ReactNative\f_sandbox\node_modules\sharp
> node-gyp rebuild
D:\ReactNative\f_sandbox\node_modules\sharp>if not defined npm_config_node_gyp (node "G:\Installed\Node\node_modules\npm\bin\node-gyp-bin\\..\..\node_modul
es\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [D:\ReactNative\f_sandbox\node_modules\sharp\build
\binding.sln]
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 (G:\Installed\Node\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "G:\\Installed\\Node\\node.exe" "G:\\Installed\\Node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\ReactNative\f_sandbox\node_modules\sharp
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "G:\\Installed\\Node\\node.exe" "G:\\Installed\\Node\\node_modules\\npm\\bin\\npm-cli.js" "install" "sharp"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! sharp#0.17.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp#0.17.3 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\ReactNative\f_sandbox\npm-debug.log
Is there any fix for this/ whats missing here?
This is not an issue with your app but an npm specific issue. You need to use the right msvs_version flag to install io packages that need node-gyp.
This is not a well tested one but first please find the version of .net framework on your machine.
Next use the version as follows
npm install socket.io --msvs_version=2012
Note: Your package name could be different

"node-gyp rebuild" error in mac

I wanted to follow this page to run JSBin locally.
I just installed xcode 8.2 in my mac. Now, npm -v returns 3.10.9; node -v returns v7.2.1. However, npm install raised errors:
/Users/softtimur/Startup/WebProjects/jsbin$ npm install
> hashring#3.0.0 install /Users/softtimur/Startup/WebProjects/jsbin/node_modules/hashring
> node-gyp rebuild
CXX(target) Release/obj.target/hashvalue/src/hashvalue.o
In file included from ../src/hashvalue.cc:1:
../../nan/nan.h:189:68: error: too many arguments to function call, expected at most 2, have 4
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
...
...
...
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
make: *** [Release/obj.target/hashvalue/src/hashvalue.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.1.0
gyp ERR! command "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/softtimur/Startup/WebProjects/jsbin/node_modules/hashring
gyp ERR! node -v v7.2.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN mocha-casperjs#0.5.8 requires a peer of casperjs#>= 1.1.0-beta3 but none was installed.
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/7.2.1/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.2.1
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! hashring#3.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hashring#3.0.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hashring package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs hashring
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls hashring
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/softtimur/Startup/WebProjects/jsbin/npm-debug.log
Does anyone know what's wrong here?
Downgrade Node to v10, like this:
brew uninstall node
brew install node#10
brew link --force --overwrite node#10
npm i should finish without errors now.
The problem is that hashring v3.0.0 depends on an older version of nan (v1.3.x), which is not compatible with recent versions of node. It should be noted that as of this writing, the current version of hashring (v3.2.0) no longer contains an addon, it's javascript only.
The hashring dependency comes from jsbin's memcached dependency, which is currently hard coded to a specific git commit hash. There was a PR to update this dependency a number of months ago but was apparently dismissed because the maintainer(s) are apparently not interested in supporting modern versions of node. You may want to create an issue on their tracker to voice your concern about node compatibility.

npm failing (gyp error and install script error) during npm install homebridge on debian

I am trying to install homebridge package on debian on my Dragonboard 410c using 'npm install -g homebridge'. However, I keep running into the following error pasted below. I have already installed nodejs-legacy.
Is there a solution to this problem, or is there an alternative way to download and install the package ánd its dependencies without npm?
npm WARN excluding symbolic link utils/ncov -> lib/ncov.js
\
curve25519#1.1.0 install /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/curve25519
node-gyp rebuild
(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
make: Entering directory '/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/curve25519/build'
CXX(target) Release/obj.target/curve/node_curve.o
SOLINK_MODULE(target) Release/obj.target/curve.node
COPY Release/curve.node
make: Leaving directory '/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/curve25519/build'
npm WARN excluding symbolic link utils/ncov -> lib/ncov.js
bignum#0.11.0 install /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/srp/node_modules/bignum
node-gyp configure build
(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
gyp: Undefined variable openssl_config_path in binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.4.0-linaro-lt-qcom
gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "configure" "build"
gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/srp/node_modules/bignum
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
mdns#2.2.11 install /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns
node-gyp rebuild
path.js:424
var path = (i >= 0) ? arguments[i] : process.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at Error (native)
at Object.posix.resolve (path.js:424:50)
at Function.Module._resolveLookupPaths (module.js:249:17)
at Function.Module._resolveFilename (module.js:327:31)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/usr/share/node-gyp/bin/node-gyp.js:13:11)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
npm ERR! bignum#0.11.0 install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bignum#0.11.0 install script.
npm ERR! This is most likely a problem with the bignum package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bignum
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.4.0-linaro-lt-qcom
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "homebridge"
npm ERR! cwd /home/linaro
npm ERR! node -v v4.2.2
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
ed25519#0.0.3 install /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/ed25519
node-gyp rebuild
I'd recommend trying your commands from a different directory. I was trying to install a specific module in
/Users/my_username/.nvm/versions/node/v8.11.3/lib/node_modules/
and it was failing with a very similar error. I moved to
/Users/my_username/.nvm/versions/
(accidentally) ran npm install and it's working now.
I also discovered npm doctor in this process, which may help you get to the bottom of your problem.

"node build.js" fails when trying to install grunt-sass

I'm trying to switch from grunt-contrib-sass to grunt-sass, but I'm running into build errors related to node-sass inside the grunt wrapper module. So far I've upgraded node from 0.10.40 to 0.12.7 and switched to Python 2.7 in order to bypass a few other others, but this is what remains:
$ npm install
> node-sass#1.0.3 install /var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass
> node build.js
child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass/build'
CXX(target) Release/obj.target/binding/binding.o
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [Release/obj.target/binding/binding.o] Error 1
make: Leaving directory `/var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 2.6.18-274.18.1.el5.centos.plus
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
Build failed
npm ERR! Linux 2.6.18-274.18.1.el5.centos.plus
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! node-sass#1.0.3 install: `node build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#1.0.3 install script 'node build.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node build.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/example.com/www/npm-debug.log
Additional version info:
$ node -v
v0.12.7
$ node -v
v0.12.7
$ npm -v
2.11.3
$ cat /etc/redhat-release
CentOS release 5.11 (Final)
I'm a bit out of my depth on troubleshooting Node.js compatibility problems. While this is on a shared dev environment, I'm willing to try just about anything short of massive global change like upgrading the OS.
Update: I've since solved this by manually removing node-sass and node-gyp from the local node_modules folder. After that running npm install ran without errors. I think those modules were leftover from earlier attempts (before upgrading node.js and Python, most likely).

Resources