Google App Engine - The engine "node" is incompatible with this module - node.js

This questions has been asked many times already, and I checked all the answers but none of them helped me.
I'm trying to deploy a NodeJs app to GAE using a app.yml file. It was working perfectly until my last Github PR on it where I upgraded some nodes modules.
Now I'm getting the Error The engine "node" is incompatible with this module. Expected version "16.x.x". Got "12.19.0".
As you can see I'm up to date on my computer. I also removed and install Node, Npm and Yarn tonight just to be sure.
node -v
v16.15.0
npm -v
8.5.5
yarn -v
1.22.18
I tried deploying the app with a specific node version on my packages.json but with or without it's not working.
"engines": {
"node": "16.x.x"
},
I also tried to remove the cache on GAE using this, without no effect.
default_expiration: '0d 0h'
On my app.yml I'm using nodejs en Env: flex:
runtime: nodejs
env: flex
I can't use node16 as I need env: flex.
Of course I tried to delete the Node_modules and yarn.lock for at least 100 times but still nothing, always the same error.
Nothing change on the app.yml file since the last deployment. The only thing is that I upgraded some Node Modules.
On the Yarn side I've tried:
yarn install --force
yarn install --ignore-engines
yarn cache clean --all
But still not working.
Any help will be really grateful.

I had the same issue. The error is because the image used by google is fixed to the version 12.19.0, check here for more info.
My workaround was use a custom image:
Change in the app.yaml file the runtime to custom.
runtime: custom
env: flex
...
Create a Dockerfile file with the following content:
FROM gcr.io/google_appengine/nodejs
# Current Node LTS version.
RUN /usr/local/bin/install_node '16.16.0'
RUN npm install --unsafe-perm --global yarn
COPY . /app/
RUN yarn install --production || \
((if [ -f yarn-error.log ]; then \
cat yarn-error.log; \
fi) && false)
CMD yarn start

Related

Yarn command "develop" not found

For reference, the goal is to design a blog website on github using .mdx format.
I'm trying to run a prebuilt docker container (I did not compose the image) using an M1 Mac. For ambiguity's sake - let's say the container image is called "docker run -it -p "8881:8000" -v "$PWD:/app" "xxxxxxxx/yyy-zzz-purpose-of-container". One of the container dependencies is yarn, as can be seen from the output. Also, the yarn command "develop" is erroring as not found. Aside from the seemingly inocuous license output, the CLI displays:
warning package.json: No license field error Command "develop" not found.
I then tried to run it natively without the docker image as a node.js sequence of commands, and received the same error.
nvm install --lts="Gallium"
nvm alias default 'lts/Gallium'
npm install -g npm
npm install -g gatsby-cli
npm install -g yarn
yarn install .
yarn run develop
I get the same error as with the container.

How to make docker build (& Docerfile) respect the node version I set in package.json?

Our Node.js project requires Node version 14 or higher, so I set that in the package.json
"engines": {
"node": ">=14"
}
But the Dockerfile (some other developer wrote it) did not respect that, it looks like these
FROM node:12-alpine3.14
COPY package*.json ./
ENV NODE_ENV production
# RUN npm install -g npm#latest
RUN npm install
...
docker build succeeded but docker run failed exactly because of node 12.
How can I make docker build respect the nodejs version I set in the package.json?
Please note that the problem is easily fixed by just update FROM node:14-alpine3.14. But that is not my question is about. For example, say in the future the project needs node16 and we update that in package.json but forget to update the Dockerfile, I need a way to make docker build failed for that reason.
I think make docker build failed is probably the only way (refer to Make docker build fail if tests fail too).
So I find 2 ways to do that.
A) By using RUN yarn instead of RUN npm install in the Dockerfile, so yarn will issue the error and docker build failed. Then by checking the failed message someone who builds the docker image will know the dockerfile needs to update.
#11 The engine "node" is incompatible with this module. Expected version ">=14". Got "12.22.8"
#11 1.363 error Found incompatible module.
#11 1.364 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
executor failed running [/bin/sh -c yarn]: exit code: 1
B) Create a .npmrc and set engine-strict=true so npm install will fail. Check How to specify/enforce a specific node.js version to use in package.json?

Create-react-app returns "Cannot find module 'rxjs'"

I've just installed NodeJS and NPM in a new machine. I added rxjs package in all my existing projects in order to make then start properly. However, when I run create-react-app - using npm globally or npx - I receive "Error: Cannot find module 'rxjs'
". Seems like rxjs is a new dependency of something (considering it's affecting old projects too).
I have already changed Node version to 8, 10 and 12. Reinstalled NPM, changed CRA version to 2.x.x and the trouble persists.
How can I use CRA without this problem?
As mentioned by the Original Poster in the comments, the fix could be to clear your cache.
npm cache clean --force
If this still doesn't work, you can follow the steps below to install and try with Yarn:
If neither npx create-react-app my-app and npm init react-app my-app are working for you, try Yarn to see how it goes.
I have used CRA is multiple projects on Windows, Ubuntu, Mint and macOS and have never explicitly installed rxjs, nor have I been asked for it. This leads me to think that this problem is almost certainly caused by sth local to you rather than sth wrong with CRA. I assume that you have searched through their issues on Github.
Try it with Yarn
Open a new terminal (linux and macOS) or command line (Windows) session cd'd to your documents folder or suitable alternative. Then run:
macOS
brew install yarn
yarn create react-app my-app
Windows (with Chocolatey)
choco install yarn
yarn create react-app my-app
Ubuntu
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
yarn create react-app my-app

yarn command not found in gitlab ci

I am trying to configure my gitlab-ci to use yarn install instead of npm install
My current gitlab-ci.yml looks like:
image: node:6.9.4
cache:
paths:
- node_modules/
- .yarn
before_script:
- apt-get update -qq && apt-get install -qy libelf1
stages:
- test
test_core:
stage: test
script:
- yarn config set cache-folder .yarn
- yarn install
- npm run build
- npm run test
tags:
- 2gb
But the build fails with the error:
/bin/bash: line 48: yarn: command not found
is there something I am missing?
I tried installing yarn with:
curl -o- -L https://yarnpkg.com/install.sh | bash
this gave me same error, probably because I need to reload the bash environment for the yarn command to become available.
The above config works perfect with npm install.
Please help me resolve this. If there is something missing in my config file or there is something wrong with the gitlab-ci.
Thanks.
Solved it by using the latest official node docker image.
Since image: 6.10.0, yarn is installed by default in the image.
But if you need node-gyp to build any package, it needs to be installed by adding a line to the script:
yarn global add node-gyp
Add the following to your ci script after yarn got installed:
export PATH=$HOME/.yarn/bin:$PATH
I use image:node:latest and sometimes it prompts the error. Clear Runner Caches do the job for me. Maybe the runner did not recover to the correct state after doing other jobs.
I solved it by using npx (package runner). It's better then extending docker-image only for this purpose
npx yarn someCommand

Docker Compose w/ Gulp - Local gulp not found

I am attempting to use gulp inside a Docker container.
I have the following Dockerfile
FROM golang:alpine
RUN apk --update add --no-cache git nodejs
RUN npm install --global gulp
ENV GOPATH=/go PATH=$PATH:/go/bin
VOLUME ["/go/src/github.com/me/sandbox", "/go/pkg","/go/bin"]
WORKDIR /go/src/github.com/me/sandbox
CMD ["gulp"]
and I have the following docker-compose.yml
version: '2'
services:
service:
build: ./service
volumes:
- ./service/src/:/go/src/github.com/me/sandbox
docker-compose build builds successfully, but when I run docker-compose up, I get the following error message
Recreating sandbox_service_1
Attaching to sandbox_service_1
service_1 | [22:03:40] Local gulp not found in /go/src/github.com/me/sandbox
service_1 | [22:03:40] Try running: npm install gulp
I have tried several different things to try to fix it.
Tried also installing gulp-cli globally and locally
Tried installing gulp locally with npm install gulp
Tried moving the npm install --global gulp after the WORKDIR
Tried different paths for volumes.
My guess is that it has something to do with the volumes, because when I get rid of anything having to do with a volume, it doesn't complain.
Mr project structure is shown in screenshot below:
This is what worked for me.
RUN npm install -g gulp
RUN npm link gulp
You need a local version of gulp as well as a global one.
Adding this line should fix your issue
RUN npm i gulp

Resources