[Bugs] Can't Start Strapi - Need help - Emergency

System Information
  • Strapi Version: 0.1.0
  • Operating System: Mac M1
  • Database: Postgres
  • Node Version: 18 Alphine
  • NPM Version: 6
  • Yarn Version:

Here Is my Package.json:
{
“name”: “ta-io-strapi”,
“private”: true,
“version”: “0.1.0”,
“description”: “A Strapi application”,
“scripts”: {
“develop”: “strapi develop”,
“start”: “strapi start”,
“build”: “strapi build”,
“strapi”: “strapi”
},
“dependencies”: {
@strapi/plugin-documentation”: “^4.13.4”,
@strapi/plugin-i18n”: “^4.16.2”,
@strapi/plugin-sentry”: “^4.16.2”,
@strapi/plugin-users-permissions”: “^4.16.2”,
@strapi/strapi”: “^4.16.2”,
“better-sqlite3”: “8.5.0”,
“md5”: “^2.3.0”,
“pg”: “^8.11.3”,
“react”: “^18.2.0”,
“react-dom”: “^18.2.0”,
“react-router-dom”: “^5.3.4”,
“sharp”: “^0.32.5”,
“styled-components”: “^5.3.3”
},
“author”: {
“name”: “A Strapi developer”
},
“strapi”: {
“uuid”: “20e0b7f0-a399-4618-af40-72673ae39e08”
},
“engines”: {
“node”: “>=14.0.0 <=20.x.x”,
“npm”: “>=6.0.0”
},
“license”: “MIT”
}

Here is my Docker:
FROM node:18-alpine

Installing libvips-dev for sharp Compatibility

RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev

ARG NODE_ENV=development

ENV NODE_ENV=${NODE_ENV}

ENV APP_KEYS=randomKey

ENV API_TOKEN_SALT=randomSalt

ENV TRANSFER_TOKEN_SALT=randomToken

ENV ADMIN_JWT_SECRET=randomSecret

WORKDIR /opt/

COPY package.json ./

RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install && npm update

ENV PATH /opt/node_modules/.bin:$PATH

WORKDIR /opt/app

COPY . .

RUN chown -R node:node /opt/app

USER node

RUN [“npm”, “run”, “build”]

EXPOSE 8080

ARG STRAPI_COMMAND=start

ENV STRAPI_COMMAND=${STRAPI_COMMAND}

CMD npm run $STRAPI_COMMAND

here is my bug log:
Executing task: docker logs --tail 1000 -f 9c9d41dee11596bffedfae7314aa2a4d361ef58c41f1c61696b144dfe0feb9eb

ta-io-strapi@0.1.0 develop
strapi develop

  • Building build context

[INFO] Including the following ENV variables as part of the JS bundle:
- ADMIN_PATH
- STRAPI_ADMIN_BACKEND_URL
- STRAPI_TELEMETRY_DISABLED
:heavy_check_mark: Building build context (67ms)

  • Creating admin
    ✘ [ERROR] Cannot start service: Host version “0.16.17” does not match binary version “0.19.2”

1 error
[ERROR] The service is no longer running
[ERROR] There seems to be an unexpected error, try again with --debug for more information

Everything run succcessfully, until today, even old branch can’t build, I have fixed it to build successfully, but can’t start container.

Please help,

Thanks

1 Like

I have figured out the issue, actually because all dependencies are too old, I need to update all dependencies with npm update.

The error pops out 0.16.17 is ESBUILD VERSION, the last piece is to update ESBUILD.

Thanks,

Please help close this topic,

Thanks,

B/R

@AlexNguyen I am getting same error. Can you explain what did you update?

First, My operation is Mac, Linux. I am not sure what you have to do if you use window.

For update parts, Please do follow things.

First, make sure you use node >= 18, I am using node 18:alpine.

Second, everytime you try to build again, make sure you have already delete these folders:

  1. node_modules
  2. cache
  3. build
  4. package.lock.json (keep package.json)

Then run: npm install
Then run: npm update

If possible, put these commands in docker file.
Then run build.

If there is a failed build, please read log and check whether you have to install new dependencies or your current dependencies is old.

Like me it pop out 0.16.17 is old, I have to search through project to check whether which depedency is 0.16.17 and run update.

Thanks,

B/R

I think this is something related to node versions. Make sure you have same node version in docker, local machine, and in strapi.

And also strapi recommends to use node LTS versions.

Thanks for the quick reply. Strapi is working on my macbook but not working on local docker.

Platform: macbook m2
Node: v18.18.0
Yarn: 1.22.19
@strapi/plugin-cloud”: “4.16.2”,
@strapi/plugin-i18n”: “4.16.2”,
@strapi/plugin-users-permissions”: “4.16.2”,
@strapi/strapi”: “4.16.2”,

"[ERROR] Cannot start service: Host version “0.16.17” does not match binary version “0.19.2”

Docker File taken from Strapi documentation.

FROM node:18-alpine
# Installing libvips-dev for sharp Compatibility
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}

WORKDIR /opt/
COPY package.json yarn.lock ./
RUN yarn global add node-gyp
RUN yarn config set network-timeout 600000 -g && yarn install
ENV PATH /opt/node_modules/.bin:$PATH

WORKDIR /opt/app
COPY . .
RUN chown -R node:node /opt/app
USER node
RUN ["yarn", "build"]
EXPOSE 1337
CMD ["yarn", "develop"]

One of the problem is @strapi/admin@4.16.2 uses dependencies:

  1. esbuild "0.19.2"
  2. esbuild-loader "^2.21.0"

But esbuild-loader@^2.21.0: uses dependencies:

  1. esbuild "^0.16.17"

So there is version mismatch for esbuild stating
Cannot start service: Host version "0.16.17" does not match binary version "0.19.2"

Not sure why this works on macbook but not on local docker. Might me version mismatch for node, yarn or other things.

1 Like

Yes so your case nearly like mine.

Delete package.lock.json or yarn.lock, cache, build, node_modules.

run:
npm install esbuild@latest --save-dev
npm install

try this.
Thanks

@AlexNguyen I might be wrong over here or I have missed some steps:

It did not work following your steps. I was getting the same error. Also tried with strapi version “4.15.0” in a new project but no luck.

What Worked:
I missed .dockerignore file in the project so I added one:

.tmp/
.cache/
.git/
build/
node_modules/
data/

Then it was working fine. Maybe node_modules were copied too. I dont know. Very new to docker and strapi.

4 Likes

I can confirm this worked! What I did was add node_modules and package-lock.json. This draws me a conclusion that perhaps the Dockerfile copied the node_modules too!

1 Like

Thanks for sharing, I had the same issue and your solution help me to resolve it

I would Recommend to leave the package-lock.json in there.
or you might run into issues at some point as your local packages might differ from the docker installed ones as they dont have a lockfile and might resolve differently

1 Like