Native Compilation failing for NPM Package

I followed this post to have the nodejs and npm setup on Linux. The native compilation is failing for the sqlite3 package.

I get the following error:

root@colibri-imx6:~# npm install sqlite3
-\|/-
> sqlite3@3.1.8 install /home/root/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.8/node-v46-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.8 and node@4.6.1 (node-v46 ABI) (falling back to source compile with node-gyp) 
Traceback (most recent call last):
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 13, in <module>
    import gyp
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 13, in <module>
    import gyp.common
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py", line 9, in <module>
    import filecmp
ImportError: No module named filecmp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305: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.1.35-v2.7b1+gc117783
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/root/node_modules/sqlite3/lib/binding/node-v46"
gyp ERR! cwd /home/root/node_modules/sqlite3
gyp ERR! node -v v4.6.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 '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/root/node_modules/sqli)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/root/node_modules/sqlite3/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:829: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.35-v2.7b1+gc117783
node-pre-gyp ERR! command "/usr/bin/node" "/home/root/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/root/node_modules/sqlite3
node-pre-gyp ERR! node -v v4.6.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.31
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/root/node_modules/sqlite3/lib/binding/node-v46-linux-)
npm ERR! Linux 4.1.35-v2.7b1+gc117783
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "sqlite3"
npm ERR! node v4.6.1
npm ERR! npm  v2.15.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! 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 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!     /home/root/npm-debug.log
root@colibri-imx6:~# 

I am using Colibri_iMX6_LinuxImageV2.7_20170112 (Angstrom v2016.12 - Kernel 4.1.35-v2.7b1+gc117783).

Hi

Line 16, 17 point to the answer.
Obviously some python code tries to include the module ‘filecmp’ but that is not installed.

Max

I couldn’t get the npm sqlite3 package to compile on iMX6, ended up with cross-compiling it and transferring it to iMX6.

Thanks.