"Cannot read property 'package' of undefined"
Hello,
I want to build an Alexa Skill using typescript and serverless - which are both quite new for me. The basic code - before I added typescript - was running just fine. But with typescript I got an error:
Using powershell and tried to get more infos with the SLS_DEBUG. It showed me an error for the serverless-plugin-typescript
cmd /c "set `"SLS_DEBUG=*`" & serverless invoke local --verbose -f browserkiosk -p ./testdata/deepSpecificPicture.json "
Serverless: Load command run
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 emit
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Invoke invoke:local
Type Error ---------------------------------------------
Cannot read property 'package' of undefined
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: Cannot read property 'package' of undefined
at TypeScriptPlugin.prepare (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:70:29)
at TypeScriptPlugin.<anonymous> (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:104:18)
at Generator.next (<anonymous>)
at C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:7:71
at new Promise (<anonymous>)
at __awaiter (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:3:12)
at TypeScriptPlugin.compileTs (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:103:16)
at TypeScriptPlugin.<anonymous> (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:41:48)
at Generator.next (<anonymous>)
at C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:7:71
at new Promise (<anonymous>)
at __awaiter (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:3:12)
at Object.before:invoke:local:invoke [as hook] (C:\GoogleDrive\03_Codes\Alexa\AlexaSkills_ASK-CLI\browserkiosk\lambda\custom\node_modules\serverless-plugin-typescript\dist\src\index.js:40:49)
at BbPromise.reduce (C:\Users\jpteb\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:372:55)
From previous event:
at PluginManager.invoke (C:\Users\jpteb\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:372:22) at PluginManager.run (C:\Users\jpteb\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:403:17)
at variables.populateService.then (C:\Users\jpteb\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:102:33)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
From previous event:
at Serverless.run (C:\Users\jpteb\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:89:74)
at serverless.init.then (C:\Users\jpteb\AppData\Roaming\npm\node_modules\serverless\bin\serverless:42:50)
at <anonymous>
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: win32
Node Version: 8.10.0
Serverless Version: 1.27.0
My additions on typescript in the serverless.yml
plugins:
- serverless-offline
- serverless-plugin-typescript
My additions in the package.json
"dependencies": {
"ask-sdk": "^2.0.1"
},
"devDependencies": {
"@types/node": "^10.0.2",
"serverless-offline": "^3.20.3",
"serverless-plugin-typescript": "^1.1.5"
},
Does anybody have a clue how to handle this? Didn't I set it up correctly?
Got the exact same problem, not sure what is going wrong.
For me, this happened when I was in a wrong directory and tried to invoke a function that didn’t exist.
Solved by switching to the right directory and specifying the correct function name.
I got this issue when I try to invoke the wrong function name. Just make sure you put the right name.
serverless invoke local -f [FIX_THIS] -p ./testdata/deepSpecificPicture.json