0

我正在尝试通过 docker 离线运行无服务器框架应用程序,我在 Dockerfile 和 package.json 文件中指定了最新的节点版本,但仍然看到我使用旧版本的错误。

错误是 - serverless-offline 需要 node.js 版本 10.13.0 或更高,但找到版本 8.12.0。请升级!

包.json

# File: ./Dockerfile
FROM node:14.17.0
# Copy the package.json and package.lock.json file to the image
WORKDIR /usr/src/app
COPY package*.json ./
# Run `npm install` to install the dependencies in the 
# package.json file
RUN npm install
# Copy the contents of the project to the image
COPY . .
# This is the default port the serverless framework will 
# listen on when it starts
EXPOSE 3000
# These are just to remind me that these are the
# environment variables this project uses
# ENV AWS_ENDPOINT='http://localhost:8000'
# ENV AWS_REGION='us-west-1'
# ENV AWS_ACCESS_KEY_ID='from-dockerfile-fake-access-key'
# ENV AWS_SECRET_ACCESS_KEY='from-dockerfile-fake-secret-key'
# Run 'npm start' when the container starts.
# This will start serverless, in offline mode, just like
# running the project from the terminal locally
CMD [ "npm", "start" ]

包.json

{
  "name": "items-api",
  "version": "1.0.0",
  "description": "Items API",
  "private": true,
  "repository": {
    "type": "git",
    "url": "https://github.com/xxx/xxx-api-task"
  },
  "author": "xxx",
  "scripts": {
    "sls": "serverless",
    "seed": "node ./seed/runner.js",
    "start": "sls offline start",
    "test": "jest",
    "test:coverage": "jest --coverage",
    "test:v": "npm test -- --verbose",
    "deploy": "serverless deploy --aws-profile serverless",
    "package": "serverless package"
  },
  "engines": {
    "node": "~14.17.0"
  },
  "devDependencies": {
    "aws-sdk": "^2.694.0",
    "jest": "^26.0.1",
    "serverless": "^1.72.0",
    "serverless-offline": "^6.4.0"
  }
}

4

0 回答 0