I'm unable to deploy functions. The node_modules/@grpc/grpc-js file contains a dependency on node 8.4:
"engines": {
"node": ">=8.4"
},
The error message reads:
⚠ functions[query_exchange_trades_eu(europe-west1)]: Deployment error.
Build failed: {"message": "yarn_installhad stderr output:nerror @grpc/[email protected]: The engine \"node\" is incompatible with this module. Expected version \"^8.11.2 || >=9.4\".nerror Found incompatible modulennerror:yarn_installreturned code: 1", "code": 1, "type": "USER_ERROR"}
My package.json contains "engines": {"node": "8"} as described here.
Any ideas as to what this means?
$ node --version
v8.11.3
$ firebase --version
6.1.0
$ yarn --version
1.10.1
package.json:
"firebase-admin": "^6.1.0",
"firebase-functions": "^2.1.0",
i have node 8.12.0,
"engines": {
"node": "8"
},
, use yarn install --ignore-engines and in this way it downloads the package and later deploys fine
@rilian is correct - you'll have to tell yarn to ignore the engines specification.
Firebase Functions runs on node 8.11.1. You'd see the same error if you installed that version of node on your own machine.
@rilian @bkendall I am not sure how to do that.
For example when I deploy with npx firebase deploy --project production --only functions:sendPendingNotifications, the predeploy scripts from my firebase.json get executed, but yarn install is not one of them.
I do not explicitly tell the deployment to run yarn install anywhere, so I don't know where to add that option 😕
@0x80 do you get this issue after you remove node_modules and reinstall packages with --ignore-engines flag and then deploy ?
@rilian yes I still get this error then. I have predeploy scripts configured in my firebase.json. Maybe that makes a difference?
{
"functions": {
"source": ".",
"predeploy": ["yarn lint", "yarn build"],
"ignore": [
"Dockerfile",
"Dockerfile.*",
"*.log",
".DS_Store",
".env",
".env.*",
".git",
".gitignore",
".vscode",
"node_modules"
]
}
}
The predeploy phase triggers a lint and build of my source (which is Typescript) and uploads the root directory including the built javascript files. As you can see it doesn't include the node_modules folder since it is in the ignore files list. So I assume, as part of the function deployment, a yarn install is triggered in the cloud pipeline and that is causing the errors.
AFAIK I have no control over that yarn install execution, so I don't see a way for me to pass the --ignore-engines flag.
Yesterday, I was able to deploy functions under node 8 with no issues. Today, it stopped working and I'm getting the [email protected] incompatabilty error even though I didn't change a single line of code. As mentioned here:
By default, the node_modules folder is added to your .gcloudignore file and is not uploaded as part of your deployment.
So if I'm correct, you only need to deploy index.js and package.json because node_modules is ignored and the system calls yarn install anyway. So how to add the --ignore-engines as mentioned by @rilian?
@marcelmika @0x80 I just install packages locally with yarn ... --ignore-engines and also have node_modules ignored in my firebase.json. As it was written elsewhere, google cloud will install packages (i doubt they use Yarn internally) depending on your package.json (i use yarn and i have yarn.lock in firebase.json ignore as well). Probably this is not very strict. You may try to create a package-lock.json with npm and deploy it along with your functions code in order to provide exact versions of packages to install there.
I am not sure where you see this [email protected] incompatabilty but maybe that is related to ongoing incident with firebase deploys https://status.firebase.google.com/incident/Functions/18043
@rilian I suspect gcloud detects the yarn.lock file and then decides to run yarn, and if none is present it runs npm.
I think you are right in that a workaround would be to remove yarn.lock and use npm with package-lock.json instead.
I'd rather wait a bit to see if they can sort this out, since I'm not in a hurry to upgrade my dependencies.
@bkendall I doubt if this issue should have been closed if the only solution is to switch to npm. What are your thoughts?
I suspect gcloud detects the yarn.lock file and then decides to run yarn, and if none is present it runs npm.
thank you for suggestion! though my deploys are fine (except sometimes 1-2 functions gets stuck) i will try to deploy with yarn.lock and see if there is any difference
just FYI, i have tried to remove **/yarn.lock from firebase.json -> functions -> ignore and when i redeploy a function i see
⚠ functions[function_name(us-central1)]: Deployment error.
Build failed: {"message": "`yarn_install` had stderr output:\n
error @grpc/[email protected]:
The engine \"node\" is incompatible with this module.
Expected version \"^8.11.2 || >=9.4\".\nerror
Found incompatible module\n\n
error: `yarn_install` returned code: 1", "code": 1, "type": "USER_ERROR"}
for reference, in package.json i have
"engines": {
"node": "8"
}
@rilian Very good, I removed yarn.lock and the deploy suddenly works. Thanks a lot for mentioning it 👍
Btw. it may relate to the email I received yesterday:
We are contacting you to let you know that the Node.js 8 runtime on Google Cloud Functions will be updated from version 8.11.1 to version 8.14.0.
@marcelmika good to hear it works now for you :)
i also received the same message and as far as i understood the node 8.14 will only be available for testing after 13 Dec 2018 .. let's see
same problem here, it's not possible anymore to deploy functions having ayarn.lockfile
Most helpful comment
@rilian @bkendall I am not sure how to do that.
For example when I deploy with
npx firebase deploy --project production --only functions:sendPendingNotifications, the predeploy scripts from my firebase.json get executed, butyarn installis not one of them.I do not explicitly tell the deployment to run yarn install anywhere, so I don't know where to add that option 😕