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.

TypeError: Cannot convert undefined or null to object

See original GitHub issue

Hi there, I receive the TypeError: Cannot convert undefined or null to object on version 1.25.0 of your plugin, 'till version 1.24.1 it has been working seamlessly. My esbuild configuration is

    esbuild: {
      minify: false,
      bundle: true,
      sourcemap: offline,
      keepNames: true,
      logLevel: 'debug',
      legalComments: 'none',
      ...(offline && { nodePaths }),
      // if not offline don't bundle the layer package otherwise bundle them but aws-crt
      ...((!offline && { external }) || { external: ['aws-crt'] })
    }
Environment: darwin, node 17.4.0, framework 3.5.1 (local), plugin 6.1.3, SDK 4.3.2

the error stack is:

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at convertTrees (.../node_modules/serverless-esbuild/dist/packagers/npm.js:85:27)
    at NPM.getProdDependencies (.../node_modules/serverless-esbuild/dist/packagers/npm.js:141:27)
    at async EsbuildServerlessPlugin.pack (.../node_modules/serverless-esbuild/dist/pack.js:125:11)
    at async before:package:createDeploymentArtifacts (.../node_modules/serverless-esbuild/dist/index.js:83:17)
    at async PluginManager.runHooks (.../node_modules/serverless/lib/classes/plugin-manager.js:530:9)
    at async PluginManager.invoke (.../node_modules/serverless/lib/classes/plugin-manager.js:563:9)
    at async PluginManager.spawn (.../node_modules/serverless/lib/classes/plugin-manager.js:585:5)
    at async before:deploy:deploy (.../node_modules/serverless/lib/plugins/deploy.js:40:11)
    at async PluginManager.runHooks (.../node_modules/serverless/lib/classes/plugin-manager.js:530:9)
    at async PluginManager.invoke (.../node_modules/serverless/lib/classes/plugin-manager.js:563:9)
    at async PluginManager.run (.../node_modules/serverless/lib/classes/plugin-manager.js:604:7)
    at async Serverless.run (.../node_modules/serverless/lib/serverless.js:174:5)
    at async .../node_modules/serverless/scripts/serverless.js:687:9

I would like to maintain your package updated. Cheers!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

2reactions
gparonitticommented, Mar 2, 2022

Hi Sam, thank you for the prompt support. This is the console log output:

parsedDeps: {
  "version": "1.0.0",
  "name": "gpx-gamepix-com-sls",
  "description": "GamePix api project",
  "main": "serverless.js",
  "scripts": {
    "df": "serverless deploy function --function",
    "dynamoDb:install:permanent": "cd ./dynamodb/docker && docker-compose up -d",
    "dynamoDb:install": "serverless dynamodb install --stage loc",
    "dynamoDb:migrate": "serverless dynamodb migrate --stage loc",
    "dynamoDb:seed": "serverless dynamodb seed --stage loc --seed=mainTable",
    "dynamoDb": "serverless dynamodb start --stage loc",
    "offline": "IS_OFFLINE=true NODE_OPTIONS=--enable-source-maps serverless offline start --stage loc",
    "migrate": "serverless dynamodb migrate --stage loc",
    "exp:openapi:dev": "aws apigatewayv2 export-api --api-id **** --output-type JSON --specification OAS30 --no-include-extensions ./docs/openapi/latest-api-definition.json"
  },
  "engines": {
    "node": ">=14.15.0 "
  },
  "private": true,
  "devDependencies": {
    "eslint": "8.10.0",
    "eslint-config-standard": "16.0.3",
    "eslint-plugin-import": "2.25.4",
    "eslint-plugin-node": "11.1.0",
    "eslint-plugin-promise": "6.0.0",
    "serverless-api-gateway-caching": "1.7.5",
    "serverless-deployment-bucket": "1.5.2",
    "serverless-domain-manager": "6.0.2",
    "serverless-dynamodb-local": "0.2.40",
    "serverless-esbuild": "1.25.0",
    "serverless-iam-roles-per-function": "3.2.0",
    "serverless-offline": "8.5.0"
  },
  "author": "GamePix Srl",
  "license": "GamePix Srl. All right reserved.",
  "_id": "gpx-gamepix-com-sls@1.0.0",
  "extraneous": false,
  "path": "/Users/gianluca/development/gamepix/gpx-gamepix-com/gpx-gamepix-com-v3-sls",
  "_dependencies": {},
  "peerDependencies": {}
}

I think the problem is that, having an external layer for dependencies, I have only devDependency in the main serverless package.json so parsedDeps.dependencies is empty. I think this could be a common use case 😄 . Maybe converting the tree could be skipped in this case. Cheers!

1reaction
samchungycommented, Mar 2, 2022

Thank you! The change I made was based on no existing unit tests so thank you for that! Much appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot convert undefined or null to object - Stack Overflow
Generic answer. This error is caused when you call a function that expects an Object as its argument, but pass undefined or null...
Read more >
Cannot convert undefined or null to Object in JavaScript
The "Cannot convert undefined or null to Object" error occurs when we pass a null or an undefined value to a function that...
Read more >
Object.keys(null) possible - cannot convert undefined or null to ...
Conditions above this line allow msg===null to get into Object.keys(msg);. livedata_connection.js:1626 Uncaught TypeError: Cannot convert ...
Read more >
Cannot convert undefined or null to object - YouTube
JavaScript : How to resolve TypeError : Cannot convert undefined or null to object [ Gift : Animated Search Engine ...
Read more >
Error: "TypeError: Cannot convert undefined or nul...
Error: "TypeError: Cannot convert undefined or null to object" with Publish to Tableau Server tool. Article Options.
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