[ERR_INVALID_ARG_TYPE]: The "path"

Iam trying to use lambda with images.

The example runs ok in windows but when i put it in codebuild with linux ubuntu aws/codebuild/standard:3.0 i ran in this error.

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string or an instance of Buffer or URL. Received undefined
at readFile (fs.js:312:10)
at go$readFile (/usr/local/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:118:14)
at readFile (/usr/local/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:115:12)
at go$readFile (/codebuild/output/src178374953/src/node_modules/graceful-fs/graceful-fs.js:118:14)
at Object.readFile (/codebuild/output/src178374953/src/node_modules/graceful-fs/graceful-fs.js:115:12)
at Object.readFile (/codebuild/output/src178374953/src/node_modules/universalify/index.js:5:57)
at Object.tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
at Object.ret [as readFileAsync] (eval at makeNodePromisifiedEval (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promisify.js:184:12), :12:23)
at injectRequirements (/codebuild/output/src178374953/src/node_modules/serverless-python-requirements/lib/inject.js:23:6)
at ServerlessPythonRequirements.injectAllRequirements (/codebuild/output/src178374953/src/node_modules/serverless-python-requirements/lib/inject.js:135:12)
at ServerlessPythonRequirements. (/codebuild/output/src178374953/src/node_modules/serverless-python-requirements/index.js:188:43)
at ServerlessPythonRequirements.tryCatcher (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/codebuild/output/src178374953/src/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21)
at process.topLevelDomainCallback (domain.js:137:15)

Your Environment Information ---------------------------
Operating System: linux
Node Version: 12.16.1
Framework Version: 2.37.2
Plugin Version: 4.5.3
SDK Version: 4.2.2
Components Version: 3.9.0

This is the code that works in windows:

service: prestaciones-process

provider:
  name: aws
  lambdaHashingVersion: 20201221
  ecr:
    # In this section you can define images that will be built locally and uploaded to ECR
    images:
      appimage:
        path: ./
        
functions:
  hello:
    image:
      name: appimage

buildspec:

- git clone --branch ${USING_BRANCH} https://git-codecommit.us-east-1.amazonaws.com/v1/repos/${GITHUB_SRC_PROJECT}/
  #- ls -R -Inode_modules
  - cp ${GITHUB_SRC_PROJECT}/serverless/${PROJECT_NAME}/serverless.yml .
  - cp ${GITHUB_SRC_PROJECT}/serverless/${PROJECT_NAME}/requirements.txt .      
  - cp ${GITHUB_SRC_PROJECT}/serverless/${PROJECT_NAME}/Dockerfile .
  - bash ${GITHUB_SRC_PROJECT}/serverless/${PROJECT_NAME}/build.sh
  - apt-get update
  - apt-get install -y nodejs
  - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
  - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
  - apt-get -y install docker-ce docker-ce-cli containerd.io
  - npm install -g serverless --unsafe
  - npm i -D serverless-dotenv-plugin
  - npm install serverless-plugin-aws-alerts --save-dev
  - apt-get -y install python3-pip
  - #apt-get -y install python3.7
  - pip3 install awscli --upgrade --user
  - #mkdir key
  - #aws ssm get-parameter --name "/google-credentials/cariai-362c6bd9330a.json" --with-decryption --output json  --query Parameter.Value > key/cariai-362c6bd9330a.json
  - sls plugin install -n serverless-python-requirements
  - pip3 install -r requirements.txt
  - cat serverless.yml
  - sls --version
  - node --version
  - SLS_DEBUG=*      

This is windows config:

sls --version
Framework Core: 2.37.2
Plugin: 4.5.3
SDK: 4.2.2
Components: 3.9.0
(base) C:\Users\lbola\Downloads\temp\9>node --version
v14.16.1

Thanks in advance for the help

I did following changes and worked.

buildspec

  • apt-get update
  • npm install -g serverless --unsafe
  • apt-get -y install python3-pip
  • pip3 install awscli --upgrade --user

Follow this instructions

https://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html#troubleshooting-cannot-connect-to-docker-daemon