需要node.js版本10.13.0或更高版本,但找到版本8.12.0

需要node.js版本10.13.0或更高版本,但找到版本8.12.0,node.js,amazon-web-services,docker,npm,serverless-framework,Node.js,Amazon Web Services,Docker,Npm,Serverless Framework,我试图通过docker脱机运行无服务器框架应用程序,我在docker文件和package.json文件中指定了最新的节点版本,但仍然看到错误,我使用的是旧版本 错误是- serverless offline需要node.js版本10.13.0或更高版本,但找到了版本8.12.0。请升级 package.json # File: ./Dockerfile FROM node:14.17.0 # Copy the package.json and package.lock.json file to

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

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

package.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" ]
{
  "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"
  }
}

package.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" ]
{
  "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"
  }
}


在我的终端中,我刚刚运行了:
dockerrun-it--rm节点:14.17.0节点--version
,它的响应是“v14.17.0”。你也可以尝试一下,你会得到同样的回答。我刚刚用package.json构建了dockerfile,没有出现任何错误。