Hi, I’m trying to deploy functions with continues deployment. I’m using node.js and postgresql as db. When I try to deploy from my local system using netlify-cli it deployed successfully but when I try to build directly from git it throws following errors:
Given you have a node-gyp related error, I suggest the version of node on your local machine is lower (possibly v14.x.x) than the build system (v16.x.x). You can try downgrading node using the NODE_VERSIONenvironment variable.
Thanks for your reply. Yes my local node version is 12.22.1 and I’m using lambda-functions to run node backend with postgresql db and it is working every time I deploy changes using netlify-cli and always failed when try with git continues deployment. I understand from local system it uses dependencies installed on my system but gives error when netlify try to install them. I need a solution to overcome this node-gyp issue. I’ve tried downgrading the version as my local
NODE_VERSION
12.22.1
and tried to build again but didn’t work and gives following error.
No I’ve removed the package-lock.json file from my repo. It gives node-gyp error when I try to deploy from repository. Please check the above reply for full error log.
The error boils down to the fact you have a dependency (it appears libpq, likely stemming from pg-native) that isn’t compatible with the current version of node on the build image. node-gyp errors are often found with node-sass when the package version is not compatible with the node version, and downgrading node using NODE_VERSION environment variable will fix this in most cases. Either that or upgrading the version of node-sass being used. (I know you aren’t using node-sass, but I use it as an example because the error is the same.)
I’m hosting website on netlify but it is on other instance and continues deploy is working fine for that, issue is for backend instance. What NODE_VERSION is compatible for that? Please suggest.
I can offer no suggestions as I have no way of testing your code. If you are able to build locally specifying this version in the NODE_VERSION environment variable (as previously mentioned) will work (eg v12.22.1.)
Given it is the lambda functions that are the issue AWS_LAMBDA_JS_RUNTIME is probably a more appropriate variable (instead of NODE_VERSION which is for the build environment), but AWS uses node.js 12 by default anyway as you are using.
Without a repository to test, it is virtually impossible to provide a concrete solution.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+.
Upgrade to chokidar 3 with 15x less dependencies.
Given the version of node
Now using node v16.13.0 (npm v8.1.0)
Chokidar is likely breaking. So you would need to either downgrade the node version used using NODE_VERSION environment variable as previously explained to a compatible version (likely v12 if Chokidar break on v14+) or update the packages you are using to the latest versions so they are compatible with node v16.