can't "sudo npm install serialport" on ARMv7 Raspberry pi - node.js

Node version v4.0.0
npm verison v2.14.2
i've tried to installing node-pre-gyp & node-gyp, which seem to install fine. i've also tried to install a specific serialport v1.7.4 version. I've also tryed adding the unsafe--perm. All don't work when installing serialport
when running
sudo npm install serialport --unsafe-perm
i get the following error. I think it might be because my c++ compiler is outdated and node is trying to install non compatible node-pre-gyp. I'm both not sure what problem it is and how to solve it.
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v46-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport#4.0.7 and node#4.0.0 (node-v46 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/node_modules/serialport/build'
CXX(target) Release/obj.target/serialport/src/serialport.o
In file included from ../src/./serialport.h:7:0,
from ../src/serialport.cpp:1:
../node_modules/nan/nan.h:43:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /root/.node-gyp/4.0.0/include/node/node.h:42:0,
from ../node_modules/nan/nan.h:47,
from ../src/./serialport.h:7,
from ../src/serialport.cpp:1:
/root/.node-gyp/4.0.0/include/node/v8.h:336:1: error: expected unqualified-id before ‘using’
/root/.node-gyp/4.0.0/include/node/v8.h:469:1: error: expected unqualified-id before ‘using’
/root/.node-gyp/4.0.0/include/node/v8.h:852:1: error: expected unqualified-id before ‘using’
In file included from ../node_modules/nan/nan.h:190:0,
from ../src/./serialport.h:7,
from ../src/serialport.cpp:1:
../node_modules/nan/nan_new.h:225:1: note: template<class T, class A0, class A1, class A2, class A3> typename Nan::imp::Factory<T>::return_t Nan::New(A0, A1, A2, A3)
../node_modules/nan/nan_new.h:237:1: note: template<class T> typename Nan::imp::Factory::return_t Nan::New(Nan::FunctionCallback, v8::Local<v8::Value>)
../node_modules/nan/nan_new.h:245:1: note: template<class T, class A2> typename Nan::imp::Factory<T>::return_t Nan::New(Nan::FunctionCallback, v8::Local<v8::Value>, A2)
../src/serialport.cpp: At global scope:
../src/serialport.cpp:653:17: error: variable or field ‘init’ declared void
../src/serialport.cpp:653:13: error: ‘Handle’ is not a member of ‘v8’
../src/serialport.cpp:653:34: error: expected primary-expression before ‘>’ token
../src/serialport.cpp:653:36: error: ‘target’ was not declared in this scope
../src/serialport.cpp:670:1: error: ‘init’ was not declared in this scope
../node_modules/nan/nan_new.h: In function ‘v8::Local<T> Nan::imp::To(v8::Local<v8::Integer>) [with T = v8::Int32]’:
../node_modules/nan/nan_new.h:29:1: warning: control reaches end of non-void function [-Wreturn-type]
../src/serialport.cpp: In function ‘v8::Local<v8::Value> getValueFromObject(v8::Local<v8::Object>, std::string)’:
../src/serialport.cpp:87:1: warning: control reaches end of non-void function [-Wreturn-type]
serialport.target.mk:96: recipe for target 'Release/obj.target/serialport/src/serialport.o' failed
make: *** [Release/obj.target/serialport/src/serialport.o] Error 1
make: Leaving directory '/home/pi/node_modules/serialport/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/pi/node_modules/node-gyp/lib/build.js:285: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 4.1.19-v7+
gyp ERR! command "/usr/local/bin/node" "/home/pi/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/pi/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/home/pi/node_modules/serialport/build/Release"
gyp ERR! cwd /home/pi/node_modules/serialport
gyp ERR! node -v v4.0.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 '/usr/local/bin/node /home/pi/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:817:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.1.19-v7+
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/pi/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/pi/node_modules/serialport
node-pre-gyp ERR! node -v v4.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /home/pi/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/home/pi/node_modules/serialport/build/Release' (1)
npm ERR! Linux 4.1.19-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "serialport" "--unsafe-perm"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
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! 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 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/Desktop/QuadLink/npm-debug.log

Try this. it works npm install serialport --build-from-source

Try this:
npm i serialport --unsafe-perm --build-from-source

Related

node-gyp "Error: `make` failed with exit code" when npm install on a m2 pro

I just purchased a MacBook M2 Pro and am trying to run an old Vue project of mine with node v19.6.0 and npm 6.14.18. While doing an npm install, I'm getting 2 errors which seems to be related to node-gyp building with some other packages like fibers#5.0.3 and fsevents#1.2.9.
the fibers error look like this:
> fibers#5.0.3 install /Users/user1/Projects/project1/frontend/node_modules/fibers
> node build.js || nodejs build.js
CXX(target) Release/obj.target/fibers/src/fibers.o
../src/fibers.cc:27:65: error: no member named 'kFinalizer' in 'v8::WeakCallbackType'
handle.SetWeak(val, WeakCallbackShim<F, P>, WeakCallbackType::kFinalizer);
~~~~~~~~~~~~~~~~~~^
1 error generated.
make: *** [Release/obj.target/fibers/src/fibers.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:512:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 22.1.0
gyp ERR! command "/Users/user1/.nvm/versions/node/v19.6.0/bin/node" "/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /Users/user1/Projects/project1/frontend/node_modules/fibers
gyp ERR! node -v v19.6.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
node-gyp exited with code: 1
the fsevents errors look like this:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(403): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v111-darwin-arm64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for fsevents#1.2.9 and node#19.6.0 (node-v111 ABI, unknown) (falling back to source compile with node-gyp)
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:6:
In file included from ../../nan/nan.h:174:
../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
typedef v8::Local<v8::AccessorSignature> Sig;
~~~~^
In file included from ../fsevents.cc:6:
../../nan/nan.h:2536:8: error: no matching member function for call to 'SetAccessor'
tpl->SetAccessor(
~~~~~^~~~~~~~~~~
/Users/user1/Library/Caches/node-gyp/19.6.0/include/node/v8-template.h:814:8: note: candidate function not viable: no known conversion from 'imp::Sig' (aka 'int') to 'v8::SideEffectType' for 7th argument
void SetAccessor(
^
/Users/user1/Library/Caches/node-gyp/19.6.0/include/node/v8-template.h:807:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'v8::AccessorGetterCallback' (aka 'void (*)(Local<v8::String>, const PropertyCallbackInfo<v8::Value> &)') for 2nd argument
void SetAccessor(
^
In file included from ../fsevents.cc:6:
In file included from ../../nan/nan.h:2884:
../../nan/nan_typedarray_contents.h:34:43: error: no member named 'GetContents' in 'v8::ArrayBuffer'
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
~~~~~~~~^
3 errors generated.
make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:512:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 22.1.0
gyp ERR! command "/Users/user1/.nvm/versions/node/v19.6.0/bin/node" "/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64/fse.node" "--module_name=fse" "--module_path=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v111"
gyp ERR! cwd /Users/user1/Projects/project1/frontend/node_modules/fsevents
gyp ERR! node -v v19.6.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/user1/.nvm/versions/node/v19.6.0/bin/node /Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64/fse.node --module_name=fse --module_path=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v111' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/user1/Projects/project1/frontend/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:512:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1098:16)
node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Darwin 22.1.0
node-pre-gyp ERR! command "/Users/user1/.nvm/versions/node/v19.6.0/bin/node" "/Users/user1/Projects/project1/frontend/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/user1/Projects/project1/frontend/node_modules/fsevents
node-pre-gyp ERR! node -v v19.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute '/Users/user1/.nvm/versions/node/v19.6.0/bin/node /Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64/fse.node --module_name=fse --module_path=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v111' (1)
I already followed the instructions here https://github.com/nodejs/node-gyp#on-macos to install node-gyp, but still getting this error.
Anyone has seen this before or know how to resolve this?

how can install local-npm for having offline registery and repo for npm

I would like to have offline npm registery (like local repository) for npm modules
so I search and realized local-npm is a good idea for this.
I tried to install it but I have some problem.
I have error in installing local-npm
my command is
npm install -g local-npm --unsafe-perm=true --allow-root
and my error is:
../../nan/nan_object_wrap.h:66:61: required from here
/home/itis/.cache/node-gyp/10.24.0/include/node/v8.h:9502:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
make: *** [leveldown.target.mk:119: Release/obj.target/leveldown/src/batch.o] Error 1
make: Leaving directory '/usr/local/lib/node_modules/local-npm/node_modules/leveldown/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:191:23)
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 4.18.0-348.el8.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/local-npm/node_modules/leveldown
gyp ERR! node -v v10.24.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! leveldown#1.7.2 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the leveldown#1.7.2 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! /home/itis/.npm/_logs/2023-01-19T11_02_43_168Z-debug.log```

node-zopfli error: Failed at the node-zopfli#1.4.0 install script

while upgrading the node version from 8 to 12, node-zopfli installation is failing with below errors:
from ../src/zopfli-binding.cc:1:
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2672:44: note: candidate: v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const
V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
^~~~~~~~
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2672:44: note: candidate expects 1 argument, 0 provided
In file included from /home/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14:0,
from /home/.cache/node-gyp/12.16.1/include/node/v8.h:27,
from /home/.cache/node-gyp/12.16.1/include/node/node.h:63,
from ../src/zopfli-binding.cc:1:
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2686:31: note: candidate: v8::Local<v8::Object> v8::Value::ToObject(v8::Isolate*) const
Local<Object> ToObject(Isolate* isolate) const);
^
/home/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2686:31: note: candidate expects 1 argument, 0 provided
Local<Object> ToObject(Isolate* isolate) const);
^
/home/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
../src/zopfli-binding.cc:209:86: error: no matching function for call to ‘v8::Value::ToObject()’
const unsigned char * data = (const unsigned char*)Buffer::Data(inbuffer->ToObject());
^
In file included from /home/.cache/node-gyp/12.16.1/include/node/node.h:63:0,
from ../src/zopfli-binding.cc:1:
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2672:44: note: candidate:
v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const
V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
^~~~~~~~
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2672:44: note: candidate expects 1 argument, 0 provided
In file included from /home/.cache/node-gyp/12.16.1/include/node/v8-internal.h:14:0,
from /home/.cache/node-gyp/12.16.1/include/node/v8.h:27,
from /home/.cache/node-gyp/12.16.1/include/node/node.h:63,
from ../src/zopfli-binding.cc:1:
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2686:31: note: candidate:
v8::Local<v8::Object> v8::Value::ToObject(v8::Isolate*) const
Local<Object> ToObject(Isolate* isolate) const);
^
/home/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
/home/.cache/node-gyp/12.16.1/include/node/v8.h:2686:31: note: candidate expects 1 argument, 0 provided
Local<Object> ToObject(Isolate* isolate) const);
^
/home/.cache/node-gyp/12.16.1/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
zopfli.target.mk:143: recipe for target 'Release/obj.target/zopfli/src/zopfli-binding.o' failed
make: *** [Release/obj.target/zopfli/src/zopfli-binding.o] Error 1
make: Leaving directory '/home/node_modules/node-zopfli/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.3.0-40-generic
gyp ERR! command "/home/.nvm/versions/node/v12.16.1/bin/node" "/home/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64"
gyp ERR! cwd /home/node_modules/node-zopfli
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/home/.nvm/versions/node/v12.16.1/bin/node /home/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64/zopfli.node --module_name=zopfli --module_path=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:311:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Linux 5.3.0-40-generic
node-pre-gyp ERR! command "/home/.nvm/versions/node/v12.16.1/bin/node" "/home/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/node_modules/node-zopfli
node-pre-gyp ERR! node -v v12.16.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/home/.nvm/versions/node/v12.16.1/bin/node /home/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64/zopfli.node --module_name=zopfli --module_path=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64' (1)
zopfli.target.mk:143: recipe for target 'Release/obj.target/zopfli/src/zopfli-binding.o' failedl script
make: *** [Release/obj.target/zopfli/src/zopfli-binding.o] Error 1
make: Leaving directory '/home/node_modules/node-zopfli/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.3.0-40-generic
gyp ERR! command "/home/.nvm/versions/node/v12.16.1/bin/node" "/home/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/home/node_modules/node-zopfli/lib/binding/node-v72-linux-x64"
gyp ERR! cwd /home/node_modules/node-zopfli
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-zopfli#1.4.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-zopfli#1.4.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! /home/.npm/_logs/2020-03-16T07_09_26_729Z-debug.log
It's showing the cache issue, checked after clearing the cache and tried updating the same as well as different packages. Still, the same issue is occurring. Is this due to version or anything else. Any solution?
Thanks in advance.
It's been a while since this was asked, and I don't have an explanation, but I do have a possible solution:
Try run:
npm install -g node-gyp#latest
npm update node-sass npm update node scripts
npm rebuild node-sass
npm install --build-from-source node-zopfli
rm -rf node_modules
npm install --save react react-dom react-scripts
npm rebuild node-sass
Now try to run the project.
I'm currently working on an old project. not sure why it's built the way it does, or what is it with node-zopfli#1.4.0, but I'm now able to run the project.

Error installing Realm via npm: npm ERR! Failed at the realm#1.2.0 install script 'node-pre-gyp install --fallback-to-build'

I've found other issues regarding fallback to binary build for other node packages but none for Realm. I've tried some solutions from other scenarios such as:
removing /home/.node-gyp,
installing build-essential / installing libkrb5-dev,
removing node_modulesfrom project root and node-gyp and then doing a fresh npm install
Yet when I run npm install --save realm I get this error trace:
node-pre-gyp ERR! Tried to download(404): https://static.realm.io/node-pre-gyp/realm-v1.2.0-node-v51-linux-ia32.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for realm#1.2.0 and node#7.5.0 (node-v51 ABI) (falling back to source compile with node-gyp)
make: Entering directory `/home/..../node_modules/realm/build'
ACTION binding_gyp_vendored_realm_target_download_realm /home/..../node_modules/realm/vendor/realm-node
Downloading dependency: realm-node 2.4.0
Using cached realm-node from TMPDIR
Skipping the sync download because ENABLE_SYNC is false.
TOUCH Release/obj.target/vendored-realm.stamp
TOUCH Release/obj.target/realm-core.stamp
CXX(target) Release/obj.target/object-store/src/object-store/src/binding_callback_thread_observer.o
g++: error: unrecognized command line option ‘-std=c++14’
make: *** [Release/obj.target/object-store/src/object-store/src/binding_callback_thread_observer.o] Error 1
make: Leaving directory `/home/..../node_modules/realm/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:285:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:192:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-75-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/./node_modules/realm/compiled/node-v51_linux_ia32/realm.node" "--module_name=realm" "--module_path=/home/..../node_modules/realm/compiled/node-v51_linux_ia32"
gyp ERR! cwd /home/..../node_modules/realm
gyp ERR! node -v v7.5.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 '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/..../node_modules/realm/compiled/node-v51_linux_ia32/realm.node --module_name=realm --module_path=/home/..../node_modules/realm/compiled/node-v51_linux_ia32' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/..../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:192:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:890: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.0-75-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/..../node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/..../node_modules/realm
node-pre-gyp ERR! node -v v7.5.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/..../node_modules/realm/compiled/node-v51_linux_ia32/realm.node --module_name=realm --module_path=/home/..../node_modules/realm/compiled/node-v51_linux_ia32' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! realm#1.2.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the realm#1.2.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 realm 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
I am using node version 7.5.0 and npm version 4.5.0.
I have the node-pre-gyp package.
What is going on?!
Try the following step by step,
Install the older version in the project folder
npm install --save realm#0.14.3
Open node_modules/realm/package.json and remove this line:
"postlink": "node_modules/realm/scripts/rnpm-postlink.js"
Link
react-native link realm
The solution was found here

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