Trouble installing atlassian-connect-express application

I am attempting to run my ACE application in a Docker container. However, when I attempt to run npm install within the container (which runs Node 8.9.2 from this image: https://hub.docker.com/_/node), I get lots of errors around the sqlite3/node-pre-gyp dependency.

Here is the full log of my output: https://pastebin.com/raw/uuGXib4Q

I also get errors (albeit different ones) when I try to run npm install on my host machine, outside of the Docker container. They look like this: https://pastebin.com/raw/SzJmeW9Y

Do anyone have any insight as to what is causing these errors in each case?

package.json

{
  "name": "validator-cloud",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "atlassian-connect-express": "^2.0.3",
    "body-parser": "^1.14.2",
    "compression": "^1.6.0",
    "cookie-parser": "^1.4.0",
    "errorhandler": "^1.4.2",
    "express": "^4.13.3",
    "express-hbs": "*",
    "jugglingdb-postgres": "^0.1.0",
    "jugglingdb-sqlite3": "0.0.5",
    "morgan": "^1.6.1",
    "static-expiry": ">=0.0.5"
  }
}

Dockerfile

FROM node:8.9.2

WORKDIR /app

COPY . .

RUN npm install

docker-compose.yml

version: '2'
services:
  postgres:
    image: "postgres:9.4"
    env_file:
      - .env
  web:
    build: .
    ports:
      - "8080:8080"
    volumes:
      - .:/usr/src/app
    depends_on: 
      - postgres
    env_file:
      - .env
    command: ["npm", "start"]

Although I am not familiar with ACE, try update your npm version:

npm install -g npm@latest

or maybe use latest version of npm image?

I tried that, but then npm install immediate fails because it can’t find semver.

validator-cloud git:(add-postgres!?) docker-compose up
Pulling postgres (postgres:9.4)...
9.4: Pulling from library/postgres
f49cf87b52c1: Pull complete
67d44cf86769: Pull complete
f16a15c53831: Pull complete
9b76eec81f9c: Pull complete
c9a1ed29c8a8: Pull complete
8862935f78c7: Pull complete
8327022d2463: Pull complete
543fcabea67b: Pull complete
1a44b576a99d: Pull complete
609760b4b164: Pull complete
5046f80cef5e: Pull complete
45f157fa181a: Pull complete
Digest: sha256:4407092d1a5071933adf259b6a0da7b424a00897814fc48de42ed428a28f13b2
Status: Downloaded newer image for postgres:9.4
Building web
Step 1/5 : FROM node:8.9.2
8.9.2: Pulling from library/node
85b1f47fba49: Pull complete
ba6bd283713a: Pull complete
817c8cd48a09: Pull complete
47cc0ed96dc3: Pull complete
8888adcbd08b: Pull complete
6f2de60646b9: Pull complete
d8506b85a569: Pull complete
72244dc25e55: Pull complete
Digest: sha256:cc738a92ef939e0b746ab88cde834764f1d4a150122dfa3a71fd63faad1d0633
Status: Downloaded newer image for node:8.9.2
 ---> 4174ede1290d
Step 2/5 : WORKDIR /app
Removing intermediate container 4e4f547b57ad
 ---> 94bbc42a5886
Step 3/5 : COPY . .
 ---> e982a41f1c13
Step 4/5 : RUN npm install -g npm@latest
 ---> Running in 577053d94e2d
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
+ npm@5.6.0
added 27 packages, removed 11 packages and updated 38 packages in 9.718s
Removing intermediate container 577053d94e2d
 ---> cb575d312cdd
Step 5/5 : RUN npm install
 ---> Running in 0787e83caab4
module.js:538
    throw err;
    ^

Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
ERROR: Service 'web' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 1

No idea what that’s all about.

I also tried using the most recent version of the node image (9.5.0) but that resulted in the following errors:

➜ validator-cloud git:(add-postgres!?) docker-compose up
Pulling postgres (postgres:9.4)...
9.4: Pulling from library/postgres
f49cf87b52c1: Pull complete
67d44cf86769: Pull complete
f16a15c53831: Pull complete
9b76eec81f9c: Pull complete
c9a1ed29c8a8: Pull complete
8862935f78c7: Pull complete
8327022d2463: Pull complete
543fcabea67b: Pull complete
1a44b576a99d: Pull complete
609760b4b164: Pull complete
5046f80cef5e: Pull complete
45f157fa181a: Pull complete
Digest: sha256:4407092d1a5071933adf259b6a0da7b424a00897814fc48de42ed428a28f13b2
Status: Downloaded newer image for postgres:9.4
Building web
Step 1/4 : FROM node:9.5.0
9.5.0: Pulling from library/node
f49cf87b52c1: Already exists
7b491c575b06: Pull complete
b313b08bab3b: Pull complete
51d6678c3f0e: Pull complete
da59faba155b: Pull complete
7f84ea62c1fd: Pull complete
2c3a100270b3: Pull complete
dcdbd108c05e: Pull complete
Digest: sha256:b5831920e5956339ddbbc9f42b104490668acd0745b668f9c6b69af828a4562f
Status: Downloaded newer image for node:9.5.0
 ---> a696309517c6
Step 2/4 : WORKDIR /app
Removing intermediate container 0977ed3846bf
 ---> df76a7772ac8
Step 3/4 : COPY . .
 ---> 8e7df3b07582
Step 4/4 : RUN npm install
 ---> Running in 93c89671676b

> sqlite3@3.1.4 install /app/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/bin/node',
node-pre-gyp verb cli   '/app/node_modules/sqlite3/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@0.6.28
node-pre-gyp info using node@9.5.0 | linux | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64/node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.4/node-v59-linux-x64.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.4/node-v59-linux-x64.tar.gz
node-pre-gyp ERR! Tried to download: https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.4/node-v59-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.4 and node@9.5.0 (node-v59 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.4/node-v59-linux-x64.tar.gz
node-pre-gyp verb command build [ 'rebuild' ]
make: Entering directory '/app/node_modules/sqlite3/build'
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3090100/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3090100/sqlite3.o
  AR(target) Release/obj.target/deps/sqlite3.a
  COPY Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
In file included from ../../nan/nan.h:190:0,
                 from ../src/database.h:10,
                 from ../src/database.cc:4:
../../nan/nan_maybe_43_inl.h: In function 'Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)':
../../nan/nan_maybe_43_inl.h:88:64: warning: 'v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)' is deprecated (declared at /root/.node-gyp/9.5.0/include/node/v8.h:3114): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   return obj->ForceSet(GetCurrentContext(), key, value, attribs);
                                                                ^
../src/database.cc: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE node_sqlite3::Database::New(Nan::NAN_METHOD_ARGS_TYPE)':
../src/database.cc:132:96: error: no matching function for call to 'v8::Object::ForceSet(v8::Local<v8::String>, v8::Local<v8::String>, v8::PropertyAttribute)'
     info.This()->ForceSet(Nan::New("filename").ToLocalChecked(), info[0].As<String>(), ReadOnly);
                                                                                                ^
../src/database.cc:132:96: note: candidate is:
In file included from /root/.node-gyp/9.5.0/include/node/v8.h:26:0,
                 from /root/.node-gyp/9.5.0/include/node/node.h:63,
                 from ../../nan/nan.h:47,
                 from ../src/database.h:10,
                 from ../src/database.cc:4:
/root/.node-gyp/9.5.0/include/node/v8.h:3115:29: note: v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)
                 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
                             ^
/root/.node-gyp/9.5.0/include/node/v8config.h:318:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^
/root/.node-gyp/9.5.0/include/node/v8.h:3115:29: note:   no known conversion for argument 3 from 'v8::PropertyAttribute' to 'v8::Local<v8::Value>'
                 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
                             ^
/root/.node-gyp/9.5.0/include/node/v8config.h:318:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^
../src/database.cc:133:86: error: no matching function for call to 'v8::Object::ForceSet(v8::Local<v8::String>, Nan::imp::IntegerFactory<v8::Int32>::return_t, v8::PropertyAttribute)'
     info.This()->ForceSet(Nan::New("mode").ToLocalChecked(), Nan::New(mode), ReadOnly);
                                                                                      ^
../src/database.cc:133:86: note: candidate is:
In file included from /root/.node-gyp/9.5.0/include/node/v8.h:26:0,
                 from /root/.node-gyp/9.5.0/include/node/node.h:63,
                 from ../../nan/nan.h:47,
                 from ../src/database.h:10,
                 from ../src/database.cc:4:
/root/.node-gyp/9.5.0/include/node/v8.h:3115:29: note: v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)
                 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
                             ^
/root/.node-gyp/9.5.0/include/node/v8config.h:318:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^
/root/.node-gyp/9.5.0/include/node/v8.h:3115:29: note:   no known conversion for argument 3 from 'v8::PropertyAttribute' to 'v8::Local<v8::Value>'
                 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
                             ^
/root/.node-gyp/9.5.0/include/node/v8config.h:318:3: note: in definition of macro 'V8_DEPRECATED'
   declarator __attribute__((deprecated(message)))
   ^
../src/database.cc: In static member function 'static void node_sqlite3::Database::Work_BeginOpen(node_sqlite3::Database::Baton*)':
../src/database.cc:143:9: warning: unused variable 'status' [-Wunused-variable]
     int status = uv_queue_work(uv_default_loop(),
         ^
../src/database.cc: In static member function 'static void node_sqlite3::Database::Work_BeginClose(node_sqlite3::Database::Baton*)':
../src/database.cc:227:9: warning: unused variable 'status' [-Wunused-variable]
     int status = uv_queue_work(uv_default_loop(),
         ^
../src/database.cc: In static member function 'static void node_sqlite3::Database::Work_BeginExec(node_sqlite3::Database::Baton*)':
../src/database.cc:505:9: warning: unused variable 'status' [-Wunused-variable]
     int status = uv_queue_work(uv_default_loop(),
         ^
../src/database.cc: In static member function 'static void node_sqlite3::Database::Work_BeginLoadExtension(node_sqlite3::Database::Baton*)':
../src/database.cc:605:9: warning: unused variable 'status' [-Wunused-variable]
     int status = uv_queue_work(uv_default_loop(),
         ^
node_sqlite3.target.mk:113: recipe for target 'Release/obj.target/node_sqlite3/src/database.o' failed
make: Leaving directory '/app/node_modules/sqlite3/build'
make: *** [Release/obj.target/node_sqlite3/src/database.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:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:160:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.9.60-linuxkit-aufs
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=/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64"
gyp ERR! cwd /app/node_modules/sqlite3
gyp ERR! node -v v9.5.0
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 '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/app/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:160:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:943:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
node-pre-gyp ERR! System Linux 4.9.60-linuxkit-aufs
node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /app/node_modules/sqlite3
node-pre-gyp ERR! node -v v9.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.28
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=/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/app/node_modules/sqlite3/lib/binding/node-v59-linux-x64' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@3.1.4 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@3.1.4 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/2018-02-05T21_07_34_624Z-debug.log
ERROR: Service 'web' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 1

Hi @zena,

Using the Node.js 9.x might not be an option now as I have encountered this issue. What I did to make a successful npm install is by switching/downgrading to 8.4.0.

Hope that works for you too.

Cheers,
Ian

No dice with 8.4.0. :confused: