serverless / serverless-google-cloudfunctions

Serverless Google Cloud Functions Plugin – Adds Google Cloud Functions support to the Serverless Framework
https://www.serverless.com
MIT License
272 stars 127 forks source link

Local dependencies prevent the google cloud function from building #276

Open HariShyamU opened 2 years ago

HariShyamU commented 2 years ago

Issue description I'm trying to implement code sharing between multiple services by using npm local dependencies. Here is the code structure:

endpoints -servicename --package.json --serverless.yml

libs -database.js -auth.js -package.json

I've added the libs folder as a local dependency to my function like so:

"dependencies": { "libs": "../../libs" }

When the cloud build is initiated for deployment, I get an error shown below during deployment:

Build failed: npm ERR! code EEXIST npm ERR! syscall mkdir npm ERR! path /workspace/node_modules/libs npm ERR! errno -17 npm ERR! EEXIST: file already exists, mkdir '/workspace/node_modules/libs' npm ERR! File exists: /workspace/node_modules/libs npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly.

Service configuration (serverless.yml) content

service: servicename

provider:
  name: google
  stage: dev
  runtime: nodejs14
  region: asia-south1
  project: project-name
  credentials: "../../creds.json"

frameworkVersion: '2'

plugins:
  - serverless-google-cloudfunctions

package:
  exclude:
    - node_modules/**
    - .gitignore
    - .git/**

functions:
  get:
    handler: servicehandler
    events:
      - http: path

Command name and used flags serverless deploy --region asia-south1

Environment information Framework Core: 2.59.0 Plugin: 5.4.4 SDK: 4.3.0 Components: 3.17.1