Error: Plugin/Preset files are not allowed to export objects

I am getting error from serverless. A month ago I was able to run serverless local, build everything and deploy to AWS. Now when I am starting local development I get errors.

I am running serverless with:

  • serverless-webpack
  • serverless-s3-local
  • serverless-dynamodb-local
  • serverless-offline

I suspect that it’s serverless-offline or serverless-webpack that is the problem, but realy don’t know. Any idea how to solve this?

Node version: tried with node v6.4.0, v10.11 and v8.12
Tried with Serverless 1.26 and 1.32

I removed node_modules for each test and reinstalled.

Error without Auth0 custom authenticaton:

‘Error: Plugin/Preset files are not allowed to export objects, only functions. In /home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/babel-preset-es2015/lib/index.js’,
‘at createDescriptor (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)’,
‘at items.map (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)’,
‘at Array.map (native)’,
‘at createDescriptors (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)’,
‘at createPresetDescriptors (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)’,
‘at passPerPreset (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-descriptors.js:58:96)’,
‘at cachedFunction (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/caching.js:33:19)’,
‘at presets.presets (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-descriptors.js:29:84)’,
‘at mergeChainOpts (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-chain.js:315:26)’,
‘at /home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-chain.js:278:7’,
‘at buildRootChain (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/config-chain.js:68:29)’,
‘at loadPrivatePartialConfig (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/partial.js:85:55)’,
‘at loadFullConfig (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/full.js:43:39)’,
‘at loadOptions (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/config/index.js:27:36)’,
‘at OptionManager.init (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/core/lib/index.js:215:36)’,
‘at compile (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/register/lib/node.js:61:42)’,
‘at compileHook (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/@babel/register/lib/node.js:102:12)’,
‘at Module._compile (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/pirates/lib/index.js:77:29)’,
‘at Module._extensions…js (module.js:565:10)’,
‘at Object.newLoader [as .js] (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/pirates/lib/index.js:88:7)’,
‘at Module.load (module.js:473:32)’,
‘at tryModuleLoad (module.js:432:12)’,
‘at Function.Module._load (module.js:424:3)’,
‘at Module.require (module.js:483:17)’,
‘at require (internal/module.js:20:19)’,
‘at Object.createHandler (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/serverless-offline/src/functionHelper.js:104:21)’,
‘at server.route.handler.error (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/serverless-offline/src/index.js:581:40)’,
‘at Object.internals.handler (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/handler.js:96:36)’,
‘at request._protect.run (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/handler.js:30:23)’,
‘at internals.Protect.run (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/protect.js:64:5)’,
‘at exports.execute (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/handler.js:24:22)’,
‘at each (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:384:16)’,
‘at iterate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:36:13)’,
‘at done (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:28:25)’,
‘at internals.Auth._authenticate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:210:16)’,
‘at internals.Auth.authenticate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:202:17)’,
‘at each (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:384:16)’,
‘at iterate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:36:13)’,
‘at done (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:28:25)’,
‘at internals.state (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/route.js:357:16)’,
‘at each (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:384:16)’,
‘at iterate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:36:13)’,
‘at Object.exports.serial (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:39:9)’,
‘at internals.Request._lifecycle (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:387:11)’,
‘at internals.Request._execute (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:302:21)’,
‘at Domain.request._protect.enter (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/connection.js:261:25)’,
‘at Domain.run (domain.js:221:14)’,
‘at internals.Protect.enter (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/protect.js:80:17)’,
‘at Server. (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/connection.js:259:30)’,
‘at emitTwo (events.js:106:13)’,
‘at Server.emit (events.js:191:7)’,
‘at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)’ ]
Serverless: Replying error in handler

Error with Auth0 custom authorization:

Serverless: Running Authorization function for get /listbucket (λ: customAuthorizer)
Debug: internal, implementation, error
Error: Internal Server Error
at Object.authenticate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/serverless-offline/src/createAuthScheme.js:78:27)
at request._protect.run (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:324:34)
at internals.Protect.run (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/protect.js:64:5)
at execute (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:320:30)
at authenticate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:306:21)
at internals.Auth._authenticate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:214:19)
at internals.Auth.authenticate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/auth.js:202:17)
at each (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:384:16)
at iterate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:36:13)
at done (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:28:25)
at internals.state (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/route.js:357:16)
at each (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:384:16)
at iterate (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:36:13)
at Object.exports.serial (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/items/lib/index.js:39:9)
at internals.Request._lifecycle (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:387:11)
at internals.Request._execute (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/request.js:302:21)
at Domain.request._protect.enter (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/connection.js:261:25)
at Domain.run (domain.js:221:14)
at internals.Protect.enter (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/protect.js:80:17)
at Server. (/home/test/auth0-APIGateway-CustomAuthorizer/serverless/node_modules/hapi/lib/connection.js:259:30)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)

1 Like

Hi Brorio
I got the same issue recently as well. I have also tried multiple options:
1)Try to upgrade to babel 7
2) Try to upgrade from es2015 to env

Both don’t work. Have you resolved this issue already?
Thanks.

I am having a similar problem detailed below:

What went wrong?

Babel Migration from 7.x to 8.x
Node Migration from 8.x to 10.x

What was the config you used?

Changed targets in .babelrc from 8.10 to 10.14.1
Changed runtime in serverless.yml from 8.10 to runtime: nodejs10.14.1

What stacktrace or error message from your provider did you see?

ERROR in ./getCaseRecord.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-preset-stage-3/lib/index.js
    at createDescriptor (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
    at items.map (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at presets (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
    at mergeChainOpts (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-chain.js:320:26)
    at /Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at buildRootChain (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/config-chain.js:120:22)
    at loadPrivatePartialConfig (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/partial.js:85:55)
    at Object.loadPartialConfig (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/@babel/core/lib/config/partial.js:110:18)
    at Object.<anonymous> (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:144:26)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:3:103)
    at _next (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:5:194)
    at /Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:5:364
    at new Promise (<anonymous>)
    at Object.<anonymous> (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:5:97)
    at Object._loader (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:224:18)
    at Object.loader (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:60:18)
    at Object.<anonymous> (/Users/MyDocs/DevOps/QuickAutoTags/services/v2.crm-case-record-api/node_modules/babel-loader/lib/index.js:55:12)

Here is what is in my .babelrc file:

{
	"plugins": [],
	"presets": [
		["env", {"node": "10.14.1"}],
		"stage-3"
	]
}

Here are my dependencies in my package.json:

"devDependencies": {
    "aws-sdk": "^2.350.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.1",
    "babel-loader": "^8.0.6",
    "babel-plugin-source-map-support": "^2.0.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-3": "^6.24.1",
    "eslint": "^5.15.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-node": "^9.1.0",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-react": "^7.12.4",
    "eslint-plugin-standard": "^4.0.0",
    "jest": "^24.8.0",
    "serverless-offline": "^5.0.0",
    "serverless-webpack": "^5.1.0",
    "webpack": "^4.16.2",
    "webpack-node-externals": "^1.6.0"
  },

What do you think? I really want to stay current and use the most recent version of babel if at all possible. Does anyone know if serverless-webpack supports babel.v8 yet??

If so, how can I get them to work together considering the above info?

Thanks!

My answer to this was to get rid of load in my web pack config files