CircleCI fails to deploy "cannot find serverless-component"

All of a sudden, CircleCI fails to deploy my serverless-component application.
It used to run and deploy OK. But now, my CircleCI script refuses to deploy.
The log shows the following error:

Command failed: npm install @sls-next/serverless-component@1.17.0 --prefix /home/circleci/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /home/circleci/.serverless/components/registry/npm/@sls-next
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat ‘/home/circleci/.serverless/components/registry/npm/@sls-next
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2020-10-25T16_19_46_401Z-debug.log
at ChildProcess.exithandler (node:child_process:309:12)
at ChildProcess.emit (node:events:327:20)
at maybeClose (node:internal/child_process:1048:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5) {
killed: false,
code: 254,
signal: null,
cmd: ‘npm install @sls-next/serverless-component@1.17.0 --prefix /home/circleci/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0’,
stdout: ‘’,
stderr: ‘npm ERR! code ENOENT\n’ +
‘npm ERR! syscall lstat\n’ +
‘npm ERR! path /home/circleci/.serverless/components/registry/npm/@sls-next\n’ +
‘npm ERR! errno -2\n’ +
“npm ERR! enoent ENOENT: no such file or directory, lstat ‘/home/circleci/.serverless/components/registry/npm/@sls-next’\n” +
‘npm ERR! enoent This is related to npm not being able to find a file.\n’ +
‘npm ERR! enoent \n’ +
‘\n’ +
‘npm ERR! A complete log of this run can be found in:\n’ +
‘npm ERR! /home/circleci/.npm/_logs/2020-10-25T16_19_46_401Z-debug.log\n’
}

Strangely, I can execute all commands locally just fine, including successful deployment.

Am I missing something?
What could be going wrong here?

Thanks in advance for ideas on how to debug/solve!

1 Like

I have the same problem too. I thought it was my latest commit. But even if I tried to rebuild past success builds it still having problem finding serverless-component. Anyone has clue how to solve this problem?

No real solution yet, but I have found a workaround in the meantime over on GitHub.

For those running into simular problems:

  1. Copying the directory from the CircleCI build log where it failed.
    In my case /home/circleci/.serverless/components/registry/npm/@sls-next/serverless-component@1.17.0 .
  2. Adding a step in my CircleCI script just before npx serverless deploy step, that does
    mkdir - p [directory here] .

This fixed the deployment through CI/CD for me.

Apparently serverless/ serverless-next has introduced a bug somewhere. It includes a command that includes a —prefix, but for a directory that does not exist, so it fails.
Because this directory (at least in my case) already does exit locally, deployment from local succeeds.

More info here: https://github.com/serverless-nextjs/serverless-next.js/issues/707#issue-727497553

1 Like

Thanks for the workaround! It works for me now. Been bugged down by this for about a week now.