Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Npm install fails in Alpine Docker.... #41

Open
guzman-raphael opened this issue Sep 27, 2018 · 8 comments
Open

Npm install fails in Alpine Docker.... #41

guzman-raphael opened this issue Sep 27, 2018 · 8 comments

Comments

@guzman-raphael
Copy link

I am having an issue when trying to install the module in an Alpine Docker container.

Here is the error:

[email protected] install /app/node_modules/odbc
node-gyp configure build

make: Entering directory '/app/node_modules/odbc/build'
CXX(target) Release/obj.target/odbc_bindings/src/odbc.o
../src/odbc.cpp: In static member function 'static void ODBC::UV_AfterCreateConnection(uv_work_t*, int)':
../src/odbc.cpp:201:27: warning: 'v8::Localv8::Value Nan::Callback::Call(int, v8::Localv8::Value) const' is deprecated [-Wdeprecated-declarations]
data->cb->Call(1, info);
^
In file included from ../src/odbc.h:23:0,
from ../src/odbc.cpp:25:
../../nan/nan.h:1647:3: note: declared here
Call(int argc, v8::Localv8::Value argv[]) const {
^~~~
../src/odbc.cpp:213:48: warning: 'v8::Localv8::Value Nan::Callback::Call(v8::Localv8::Object, int, v8::Localv8::Value
) const' is deprecated [-Wdeprecated-declarations]
data->cb->Call(data->dbo->handle(), 2, info);
^
In file included from ../src/odbc.h:23:0,
from ../src/odbc.cpp:25:
../../nan/nan.h:1625:3: note: declared here
Call(v8::Localv8::Object target
^~~~
../src/odbc.cpp: In static member function 'static v8::Handlev8::Value ODBC::GetColumnValue(SQLHSTMT, Column, uint16_t*, int)':
../src/odbc.cpp:491:71: error: 'timelocal' was not declared in this scope
return scope.Escape(Nan::New((double(timelocal(&timeInfo)) * 1000)
^
../src/odbc.cpp: In static member function 'static v8::Localv8::Value ODBC::CallbackSQLError(SQLSMALLINT, SQLHANDLE, char*, Nan::Callback*)':
../src/odbc.cpp:785:19: warning: 'v8::Localv8::Value Nan::Callback::Call(int, v8::Localv8::Value*) const' is deprecated [-Wdeprecated-declarations]
cb->Call(1, info);
^
In file included from ../src/odbc.h:23:0,
from ../src/odbc.cpp:25:
../../nan/nan.h:1647:3: note: declared here
Call(int argc, v8::Localv8::Value argv[]) const {
^~~~
make: *** [odbc_bindings.target.mk:109: Release/obj.target/odbc_bindings/src/odbc.o] Error 1
gyp ERR! build error
make: Leaving directory '/app/node_modules/odbc/build'
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 emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 3.10.0-514.6.1.el7.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /app/node_modules/odbc
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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-09-27T20_03_08_832Z-debug.log
ERROR: Service 'odbc_client' failed to build: The command '/bin/sh -c mkdir /app/log && apk update && apk add freetds unixodbc-dev && apk add python && apk add make g++ && npm install' returned a non-zero code: 1


Dockerfile contents:

FROM node:8.11.4-alpine
WORKDIR /app
COPY ./package.json ./
RUN
mkdir /app/log &&
apk update &&
apk add freetds unixodbc-dev &&
apk add python &&
apk add make g++ &&
npm install
ENV PATH ./node_modules/.bin:$PATH
CMD ["top"]


package.json contents:

{
"name": "adapter",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node src/app.js",
"test": "node src/test.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"cron": "^1.4.1",
"moment-timezone": "^0.5.21",
"mqtt": "^2.18.3",
"odbc": "^1.4.5",
"winston": "^3.0.0"
}
}

@ninthclowd
Copy link

ninthclowd commented Oct 13, 2018

I'm getting the same thing when using npm to install odbc:

../src/odbc.cpp:491:71: error: 'timelocal' was not declared in this scope
return scope.Escape(Nan::New((double(timelocal(&timeInfo)) * 1000)

Possibly configure related?

@guzman-raphael
Copy link
Author

guzman-raphael commented Oct 14, 2018

I eventually got it to work by making one change to the odbc.cpp file. I'll try to make a pull request for it soon.

Moved the line "#define timelocal mktime" outside of the if block in line 489. I'm sure this has implications in other environments but works in alpine with no issues.

Just make sure to clone this repo and install from local repo in Node.

Raphael

@Fenderis
Copy link

Fenderis commented Apr 22, 2019

Had this error today and Upgrading to v2.0.0-beta.0 fixed it. Woohoo!

Edit: Also using Alpine.

@markdirish
Copy link
Collaborator

@Fenderis as you use 2.0.0 beta, feel free to post any issues you run into. Very interested in making it the next-gen for ODBC on Node.js!

@Fenderis
Copy link

Tried using it as it seemed to have compiled properly as mentionned earlier.

Unfortunately, It couldn't seem to be able to make it work.

By doing :
var db = require("odbc")();
Got : fatal error require(...) is not a function.

When doing:
require("odbc");
had an object with these properties [ 'Pool', 'Connection' ]

I ended up changing docker base image to debian instead of alpine, returned to version 1.4.6 of odbc and seems to work now.

@markdirish
Copy link
Collaborator

@Fenderis

So the API for odbc 2.0 is a little different, and can be found here (if you are interested in using the new API): https://www.npmjs.com/package/odbc/v/2.0.0-beta.1
Note to create a connection, you can call

{ Connection } = require('odbc');
const conn = new Connection(connectionString;);
cont result =  await conn.query('YOUR QUERY);

or to create a Pool

{ Pool } = require('odbc');
const pool = new Pool(connectionString);
await pool.init();
const result = pool.query('YOUR QUERY');

Both the examples above use the await syntax so will have to be used inside a function labeled with async. You can also use traditional callbacks, or .then/.catch Promise syntax.

@otang
Copy link

otang commented Jan 6, 2020

Following this since we're having the same issue with alpine docker. We will try switching to ubuntu image first, and if that fails try patching the odbc.cpp as per @guzman-raphael

@otang
Copy link

otang commented Jan 7, 2020

FYI switching to standard node docker slim worked well for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants