question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Cannot convert undefined or null to object" when running serverless deploy

See original GitHub issue

I’m following the steps from this guide. I created a new project, installed dependencies, and when I’m trying to deploy the workers that comes from the template, I have the following error: Cannot convert undefined or null to object.

Albertinas-MacBook-Pro:new-project albertina$ serverless deploy
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Packaging service...
Serverless: Excluding development dependencies...
 
  Type Error ---------------------------------------------
 
  Cannot convert undefined or null to object
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at CloudflareDeploy.getInvalidScriptNames (/Users/albertina/thirdlove/development/cloudflare-workers/new-project/node_modules/serverless-cloudflare-workers/shared/validate.js:99:40)
    at CloudflareDeploy.BB.bind.then.then (/Users/albertina/thirdlove/development/cloudflare-workers/new-project/node_modules/serverless-cloudflare-workers/deploy/cloudflareDeploy.js:48:22)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
From previous event:
    at PluginManager.invoke (/Users/albertina/.nvm/versions/node/v8.14.0/lib/node_modules/serverless/lib/classes/PluginManager.js:391:22)
    at PluginManager.run (/Users/albertina/.nvm/versions/node/v8.14.0/lib/node_modules/serverless/lib/classes/PluginManager.js:422:17)
    at variables.populateService.then.then (/Users/albertina/.nvm/versions/node/v8.14.0/lib/node_modules/serverless/lib/Serverless.js:157:33)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at Serverless.run (/Users/albertina/.nvm/versions/node/v8.14.0/lib/node_modules/serverless/lib/Serverless.js:144:8)
    at serverless.init.then (/Users/albertina/.nvm/versions/node/v8.14.0/lib/node_modules/serverless/bin/serverless:44:28)
    at <anonymous>
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           8.14.0
     Serverless Version:     1.34.1
 
Albertinas-MacBook-Pro:new-project albertina$ 

I have all of the environment variables configured, and the provider zoneId and accountId too. I’m using a CloudFlare Enterprise account, and I’ve used create --template cloudflare-workers-enterprise --path new-project to create it.

It looks like the problem is with workers that is undefined.

// /shared/validate.js
getInvalidScriptNames() {
    const { workers } = this.provider.config;
    const notValidScriptNames = Object.keys(workers).find(scriptName => {
      return !this.isValidScriptName(scriptName);
    });
    return notValidScriptNames;
  }

Is the template missing some other configuration that should be added to serverless.yml?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jspiescommented, Dec 20, 2018

I’m closing this as the PR got merged. Also, version 1.0.6 is now available which makes the name parameter optional.

0reactions
jspiescommented, Dec 20, 2018

Thanks for the PR’s. I’ll look at making name optional, as most other providers have it as optional. Right now it does have to match as it uses name to lookup the function in processing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "Cannot convert undefined or null to object" when ...
Getting the below error message when running the sls deploy command. D:\Mobile Apps\ACT-Nurse-Portal\API\ACTNextGen-Services\timeSheets>sls ...
Read more >
Cannot convert undefined or null to object · Issue #972 - GitHub
I was missing the entry for the serverless-offline plugin in my serverless.ts file. Adding it in fixed the problem. 2
Read more >
TypeError: Cannot convert undefined or null to object: point ...
Either put Object.assign within the map (or forEach, since it doesn't return anything). Or take a look at Object.fromEntries.
Read more >
TypeError: Cannot convert undefined or null to object #286
Hi there, I receive the TypeError: Cannot convert undefined or null to ... node_modules/serverless/lib/plugins/deploy.js:40:11) at async PluginManager.
Read more >
Cannot convert undefined or null to object at Function.keys ...
I am trying to deploy a dev environment in AWS amplify of a react app with Vite and implementing CometChat ui kit for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found