components
components copied to clipboard
Cannot run custom method
Description
npm install -g serverless
mkdir foobar
cd foobar
npm init -f
npm install serverless-next.js --save-dev
echo "myNextApplication:\n component: serverless-next.js" > serverless.yml
sls build
Result:
error: Error: "component" input is required to run custom methods at Proxy.
(/usr/local/lib/node_modules/serverless/node_modules/@serverless/template/utils.js:350:13) at Object.runComponents (/usr/local/lib/node_modules/serverless/node_modules/@serverless/cli/src/index.js:209:40)
Expected:
build custom method of component is executed
I'm running into this same issue too when attempting to try out the website component. In my case, nothing is deployed during the first deploy and then any subsequent attempt results in the error above.
@sheerun try:
sls --component=targetComponent build
Because there can be multiple components in 1 project, the cli can only assume methods like default and remove to be present on all of them. When running a custom method, you need to first specify which component you are talking about
Is there documentation for this somewhere? I tried to find it but I failed
(for --component flag)
not that I can find, I figured it out by diving into the source code. I think if the error message was updated to be more clearer, that would solve a lot of confusion. Also, it should be documented.
@sheerun did running --component work for you?
I'd just suggest instead of documenting it, to make it a positional argument so it's easy to deploy single component or run custom function of some component, so:
sls targetComponent deploydeploys single componentsls targetComponent removeremoves single componentsls targetComponent buildruns custombuildmethod of single componentsls build- informs user that you can't run custom method without specifying component
(--component flag works)
Also maybe a good a default, when only one component is defined, is to run custom method of that component.