npm install sqlite3 --build-from-source error with electron - node.js

When trying to use sqlite with electron i've been getting this error in the web console
Error: Cannot find module 'C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\el ectron-v1.4-win32-ia32\node_sqlite3.node'
After reading some posts in the site i've seen that by using
npm install sqlite3 --build-from-source
I can fix this error, however when i tried to do so i got the following message
sqlite3#3.1.8 install C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3
node-pre-gyp install --fallback-to-build
C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3>if not defined npm_config_node_gyp (node "C:\Users\Alejandro\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node "" clean )
C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3>if not defined npm_config_node_gyp (node "C:\Users\Alejandro\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32 ) else (node "" configure --fallback-to-build --module=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32 )
gyp ERR! configure error
gyp ERR! stack Error: Python executable
"C:\Users\Alejandro\AppData\Local\Programs\Python\Python35-32\python.EXE" is v3.5.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.
gyp ERR! stack at failPythonVersion (C:\Users\Alejandro\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:14)
gyp ERR! stack at C:\Users\Alejandro\AppData\Roaming\npm\node_modules\npm\node_modules\node-
gyp\lib\configure.js:443:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:197:7)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe"
"C:\Users\Alejandro\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32"
gyp ERR! cwd C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.14393
node-pre-gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-
build"
node-pre-gyp ERR! cwd C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3
node-pre-gyp ERR! node -v v6.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.31
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\Alejandro\Documents\Proyectos\format\node_modules\sqlite3\lib\binding\node-v48-win32-ia32' (1)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\Alejandro\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "sqlite3" "--build-from-source"
npm ERR! node v6.9.1
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! sqlite3#3.1.8 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3#3.1.8 install script 'node-pre-gyp install --fallback-to-build'.
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 sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sqlite3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Alejandro\Documents\Proyectos\format\npm-debug.log
I've already tried installing the node-gyp and node-pre-gyp dependancies and still get the same error

Related

after update node js 'node-gyp' module not install with npm

When I update Node js in my Linux machine (CentOS by nvm) the modules that have node-gyp and node-pre-gyp are disabled and need to be reinstalled, For example canvas, ursa, ...
i tested this solution:
I think delete this directory and clean the cache of npm is better:
rm -rf ~/.node-gyp/
rm -r node_modules/.bin/;
rm -r build/
npm cache clean
and test
npm uninstall node-gyp
npm install -g node-gyp
and
npm uninstall node-pre-gyp
npm install -g node-pre-gyp
finally:
npm install <your module>
But these two modules go wrong and the installation process is over from package.json. what can i do with this errors?
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/root/.nvm/v10.16.3/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 3.10.0-957.21.2.el7.x86_64
gyp ERR! command "/root/.nvm/v10.16.3/bin/node" "/root/.nvm/v10.16.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/root/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/root/node_modules/canvas/build/Release" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64" "--python=python2.7"
gyp ERR! cwd /root/node_modules/canvas
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/root/.nvm/v10.16.3/bin/node /root/.nvm/v10.16.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/root/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/root/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64 --python=python2.7' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/root/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 3.10.0-957.21.2.el7.x86_64
node-pre-gyp ERR! command "/root/.nvm/v10.16.3/bin/node" "/root/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /root/node_modules/canvas
node-pre-gyp ERR! node -v v10.16.3
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/root/.nvm/v10.16.3/bin/node /root/.nvm/v10.16.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/root/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/root/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64 --python=python2.7' (1)
npm WARN PartServer#6.2.0 No description
npm WARN PartServer#6.2.0 license should be a valid SPDX license expression
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas#2.6.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas#2.6.0 install 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! /root/.npm/_logs/2019-09-17T07_45_58_118Z-debug.log

Error when trying to install firebase-admin via npm

I'm getting an error when I try to install firebase-admin:
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:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-
gyp\lib\build.js:258: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.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\TOYANSK\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=C:\\Users\\TOYANSK\\Documents\\Projects\\people\\functions\\node_modules\\grpc\\src\\node\\extension_binary\\node-v48-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=C:\\Users\\TOYANSK\\Documents\\Projects\\people\\functions\\node_modules\\grpc\\src\\node\\extension_binary\\node-v48-win32-x64-unknown"
gyp ERR! cwd C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc
gyp ERR! node -v v6.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program
Files\nodejs\node.exe C:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:891:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\TOYANSK\\Documents\\Projects\\people\\functions\\node_modules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc
node-pre-gyp ERR! node -v v6.11.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\TOYANSK\Documents\Projects\people\functions\node_modules\grpc\src\node\extension_binary\node-v48-win32-x64-unknown' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc#1.7.3 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc#1.7.3 install 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\TOYANSK\AppData\Roaming\npm-cache\_logs\2018-02-09T23_37_53_013Z-debug.log
To solve this problem, I have tried a lot of things, with no success so far:
I try to update node-gyp and node-pre-gyp
I install Python and MSBuild Tools
I follow this: Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019).
I downgraded Node.js: https://www.bountysource.com/issues/38994433-failed-to-install-grpc-version-1-0-1.
And also I try to follow these steps:
Can't install firebase-admin with npm.
But nothing changes the final result. I use Windows 10 64-bit, Node.js v6.11.2 (it was 8.4.0), NPM 5.6.0.
A curious fact is that the error also occurs during the firebase init, which allows to continue even after the error in npm install.
Maybe for this reason firebase-admin has not been previously installed, even being in the package.json of the functions directory
What if you try running npm install -g windows-build-tools in Powershell as admin, as suggested in this answer?
Your stack trace includes node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\TOYANSK\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build ... which most likely means you don't have the node-gyp library installed.
The title of the question that answer addresses is npm install that requires node-gyp fails on Windows.

Not able to execute fabcar demo in Hyperledger

I am tring to execute fabcar example from Hyperledger-fabric where I have created few cars. When I try to execute
node query.js
at ../fabric-samples/fabcar I am getting an error
fabric-client not found
If I execute
npm install
I have node 6.9.0 and npm 3.10.0
I am getting error like this
> grpc#1.2.4 install /home/.../fabric-samples/fabcar/node_modules/grpc
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.2.4/node-v57-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc#1.2.4 and node#8.0.0 (node-v57 ABI) (falling back to source compile with node-gyp)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/8.0.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/.../fabric-samples/fabcar/node_modules/grpc/.node-gyp"
make: Entering directory '/home/.../fabric-samples/fabcar/node_modules/grpc/build'
make: *** No rule to make target '../.node-gyp/8.0.0/include/node/common.gypi', needed by 'Makefile'. Stop.
make: Leaving directory '/home/.../fabric-samples/fabcar/node_modules/grpc/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:276:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 4.4.0-42-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/.../fabric-samples/fabcar/node_modules/grpc/src/node/extension_binary/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/.../fabric-samples/fabcar/node_modules/grpc/src /node/extension_binary"
gyp ERR! cwd /home/.../fabric-samples/fabcar/node_modules/grpc
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/.../fabric-samples/fabcar/node_modules/grpc/src/node/extension_binary/grpc_node.node
--module_name=grpc_node --module_path=/home/.../fabric-samples/fabcar/node_modules/grpc/src/node/extension_binary' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/.../fabric-samples/fabcar/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:887:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
node-pre-gyp ERR! System Linux 4.4.0-42-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/.../fabric-samples/fabcar/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/.../fabric-samples/fabcar/node_modules/grpc
node-pre-gyp ERR! node -v v8.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.34
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules /npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/.../fabric-samples/fabcar/node_modules/grpc/src/node/extension_binary/grpc_node.node --module_name=grpc_node --module_path=/home/.../fabric-samples/fabcar/node_modules/grpc/src /node/extension_binary' (1)
fabcar#1.0.0 /home/.../fabric-samples/fabcar`-- (empty)
npm WARN fabcar#1.0.0 No repository field.
npm ERR! Linux 4.4.0-42-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v8.0.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! grpc#1.2.4 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc#1.2.4 install script 'node-pre-gyp install --fallback-to-build'.
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 grpc package
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs grpc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls grpc
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/.../fabric-samples/fabcar/npm-debug.log
npm ERR! code 1
can anyone help me to execute the code
It was solved after deleting directory node_module and then doing
npm install

Error while installing opencv in windows 7 and node version #6

I am getting following error while installing opencv in windows 7 and node version #6
> opencv#6.0.0 install C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(403): https://node-opencv.s3.amazonaws.com/opencv/v6.0.0/Relea
se/node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for opencv#6.0.0 and node#6.7.0 (node-v48 ABI) (fal
ling back to source compile with node-gyp)
C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv>if not defined npm_config_node_g
yp (node "C:\Users\admin1\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_module
s\node-gyp\bin\node-gyp.js" clean ) else (node "" clean )
C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv>if not defined npm_config_node_g
yp (node "C:\Users\admin1\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_module
s\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\admin1\Desktop\video_p
ost\video_post\node_modules\opencv\build\opencv\v6.0.0\Release\node-v48-win32-x64\opencv.node --mo
dule_name=opencv --module_path=C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv\b
uild\opencv\v6.0.0\Release\node-v48-win32-x64 ) else (node "" configure --fallback-to-build --mod
ule=C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv\build\opencv\v6.0.0\Release\
node-v48-win32-x64\opencv.node --module_name=opencv --module_path=C:\Users\admin1\Desktop\video_po
st\video_post\node_modules\opencv\build\opencv\v6.0.0\Release\node-v48-win32-x64 )
C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv\utils\find-opencv.js:39
throw new Error("ERROR: OPENCV_DIR doesn't seem to be defined");
^
Error: ERROR: OPENCV_DIR doesn't seem to be defined
at C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv\utils\find-opencv.js:39:1
9
at ChildProcess.exithandler (child_process.js:197:7)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
gyp: Call to 'node utils/find-opencv.js --cflags' returned exit status 1 while in binding.gyp. whi
le 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 (C:\Users\admin1\AppData\Roaming\npm\node_modules\npm\
node_modules\node-gyp\lib\configure.js:336: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 Windows_NT 6.1.7600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\admin1\\AppData\\Roaming\\npm\\
node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--
module=C:\\Users\\admin1\\Desktop\\video_post\\video_post\\node_modules\\opencv\\build\\opencv\\v6
.0.0\\Release\\node-v48-win32-x64\\opencv.node" "--module_name=opencv" "--module_path=C:\\Users\\a
dmin1\\Desktop\\video_post\\video_post\\node_modules\\opencv\\build\\opencv\\v6.0.0\\Release\\node
-v48-win32-x64"
gyp ERR! cwd C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv
gyp ERR! node -v v6.7.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --mod
ule=C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv\build\opencv\v6.0.0\Release\
node-v48-win32-x64\opencv.node --module_name=opencv --module_path=C:\Users\admin1\Desktop\video_po
st\video_post\node_modules\opencv\build\opencv\v6.0.0\Release\node-v48-win32-x64' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\admin1\Desktop\video_post\video_
post\node_modules\opencv\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:
5)
node-pre-gyp ERR! System Windows_NT 6.1.7600
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\admin1\\Desktop\\video
_post\\video_post\\node_modules\\opencv\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install"
"--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\admin1\Desktop\video_post\video_post\node_modules\opencv
node-pre-gyp ERR! node -v v6.7.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.34
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\admin1\Desktop\vid
eo_post\video_post\node_modules\opencv\build\opencv\v6.0.0\Release\node-v48-win32-x64\opencv.node
--module_name=opencv --module_path=C:\Users\admin1\Desktop\video_post\video_post\node_modules\open
cv\build\opencv\v6.0.0\Release\node-v48-win32-x64' (1)
npm WARN video_post# No description
npm WARN video_post# No repository field.
npm WARN video_post# No license field.
npm WARN In opencv#6.0.0 replacing bundled version of node-pre-gyp with node-pre-gyp#0.6.34
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv#6.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv#6.0.0 install script 'node-pre-gyp install --fallback-to-build'.
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 opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs opencv
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls opencv
npm ERR! There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin1\AppData\Roaming\npm-cache\_logs\2017-05-06T05_25_57_891Z-debug.log

Multiple errors while installing nodejs serialport module

I'm running raspbian on my raspberry pi 3. I'm trying to install the serialport module and many errors show up.
pi#raspberrypi:~/pmsensor $ sudo npm install --save serialport --fix-missing
This is what i get:
serialport#4.0.7 install /home/pi/pmsensor/node_modules/serialport
node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v48-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport#4.0.7 and node#6.9.5 (node-v48 ABI) (falling back to source compile with node-gyp)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.9.5"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/pi/pmsensor/node_modules/serialport/.node-gyp"
make: Entering directory '/home/pi/pmsensor/node_modules/serialport/build'
make: *** No rule to make target '../.node-gyp/6.9.5/include/node/common.gypi', needed by 'Makefile'. Stop.
make: Leaving directory '/home/pi/pmsensor/node_modules/serialport/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: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.48-v7+
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/pi/pmsensor/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/home/pi/pmsensor/node_modules/serialport/build/Release"
gyp ERR! cwd /home/pi/pmsensor/node_modules/serialport
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/pmsensor/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/pmsensor/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/pmsensor/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Linux 4.4.48-v7+
node-pre-gyp ERR! command "/usr/bin/nodejs" "/home/pi/pmsensor/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/pi/pmsensor/node_modules/serialport
node-pre-gyp ERR! node -v v6.9.5
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/pmsensor/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/pmsensor/node_modules/serialport/build/Release' (1)
npm WARN pmsensor#1.0.0 No repository field.
npm ERR! Linux 4.4.48-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--save" "serialport" "--fix-missing"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! serialport#4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport#4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
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 serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs serialport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/pmsensor/npm-debug.log
You correctly figured out how to solve this. With the raspberry pi people usually run as root (as you are) and if you want to install a binary package with root (maybe any package), you need to use the --unsafe-perm flag with npm. The node serialport docs have more information.
https://github.com/EmergingTechnologyAdvisors/node-serialport#sudo--root

Resources