agutoli / serverless-layers

Serverless.js plugin implementing AWS Lambda Layers, reducing lambda size, warm-up, and deployment time.
MIT License
230 stars 54 forks source link

Command failed: yarn --production #140

Closed nicemaker closed 1 year ago

nicemaker commented 1 year ago

I updated my packages and now I have this error as soon as I enable serverless-layer plugin:

Error: Command failed: yarn --production 
    at checkExecSyncError (node:child_process:885:11)
    at execSync (node:child_process:957:15)
    at /home/bjorn/r/pd-b/services/checkout/node_modules/cli-progress-footer/lib/private/cli-progress-footer/disable-props.js:87:41
    at handleSubProcessSync (/home/bjorn/r/pd-b/services/checkout/node_modules/cli-progress-footer/lib/private/cli-progress-footer/disable-props.js:31:36)
    at childProcess.execSync (/home/bjorn/r/pd-b/services/checkout/node_modules/cli-progress-footer/lib/private/cli-progress-footer/disable-props.js:86:11)
    at Dependencies._callee$ (/home/bjorn/r/pd-b/services/checkout/node_modules/serverless-layers/lib/package/Dependencies.js:61:24)
    at tryCatch (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
    at Generator.<anonymous> (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
    at Generator.next (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21)
    at asyncGeneratorStep (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
    at /home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
    at new Promise (<anonymous>)
    at Dependencies.<anonymous> (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12)
    at Dependencies.run (/home/bjorn/r/pd-b/services/checkout/node_modules/serverless-layers/lib/package/Dependencies.js:74:21)
    at Dependencies._callee2$ (/home/bjorn/r/pd-b/services/checkout/node_modules/serverless-layers/lib/package/Dependencies.js:156:27)
    at tryCatch (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
    at Generator.<anonymous> (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
    at Generator.next (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21)
    at asyncGeneratorStep (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/home/bjorn/r/pd-b/services/checkout/node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)

These are my installed versions (most of them):

├── @types/aws-lambda@8.10.114
├── @types/jest@29.5.1
├── @types/node@18.15.11
├── @typescript-eslint/eslint-plugin@5.50.0
├── @typescript-eslint/parser@5.50.0
├── ajv@8.12.0
├── aws-lambda@1.0.7
├── date-fns-tz@1.3.7
├── date-fns@2.29.3
├── esbuild-node-externals@1.7.0
├── esbuild@0.17.17
├── eslint@8.33.0
├── lodash@4.17.21
├── node-typescript@0.1.3
├── serverless-analyze-bundle-plugin@2.0.1
├── serverless-aws-alias@1.8.0
├── serverless-deployment-bucket@1.6.0
├── serverless-domain-manager@6.2.0
├── serverless-esbuild@1.43.1
├── serverless-layers@2.6.1
├── serverless-lift@1.20.2
├── serverless-plugin-git-variables@5.2.0
├── serverless-plugin-typescript@2.1.4
├── serverless-prune-plugin@2.0.1
├── serverless@3.30.1
├── ts-node@10.9.1
├── typescript@5.0.4
├── ulid@2.3.0
└── undici@5.21.2

Serverless.yml

  serverless-layers:
    packageManager: yarn

unfortunately I can't really say which upgrade might have broken it. But maybe you have seen this already and can tell me what I could downgradde again?

nicemaker commented 1 year ago

Additional note, i tried to run this mentioned process myself:

yarn --production
➤ YN0050: The --production option is deprecated on 'install'; use 'yarn workspaces focus' instead

So I suppose thats a problem with the yarn version, strange though, because i don't think I changed my yarn version

nicemaker commented 1 year ago

Alight, found it. in your lib/runtimes/nodejs.js it needs to be:

 this.commands = {
      npm: 'npm install --production --only=prod',
      yarn: 'yarn workspaces focus --production',
      pnpm: 'pnpm install --prod'
    };

not sure how you can check make that forward/backwards compatible. To make this work you also have to run first yarn plugin import workspace-tools as mentioned here: https://yarnpkg.com/cli/workspaces/focus That doesn't make your life easier, bummer

nicemaker commented 1 year ago

Just found the customInstallationCommand in the docs: so this works in serverless.yml

serverless-layers:
    packageManager: yarn
    customInstallationCommand: 'yarn workspaces focus --production'