Closed xMTinkerer closed 7 years ago
If you're using alexa-app server, remove all references to express
in the function/app itself. I think the call to app.express()
causes app.express
to be redefined or something like that.
Reopen if that doesn't solve it.
hmm, no dice. This is my entire server.js
:
var AlexaAppServer = require('alexa-app-server');
var instance = AlexaAppServer.start({
server_root: __dirname, // Path to root
public_html: "public_html", // Static content
app_dir: "apps", // Location of alexa-app modules
app_root: "/alexa/", // Service root
port: 8080, // Port to use
httpsPort: 8081,
httpsEnabled: true,
privateKey: 'private-key.pem',
certificate: 'cert.cer',
debug: true,
verify: false
});
Your ./apps/hello_world/index.js
is what needs to change. Post the whole code if you can't make it work.
Ah, ok, sorry I misunderstood. This is ./apps/hello_world/index.js
:
var alexa = require('alexa-app');
// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;
// Define an alexa-app
var app = new alexa.app('hello_world');
app.launch(function(req, res) {
res.say("Hello World!!");
});
app.intent('NameIntent', {
"slots": { "NAME": "LITERAL", "AGE": "NUMBER" },
"utterances": ["{My name is|my name's} {matt|bob|bill|jake|nancy|mary|jane|NAME} and I am {1-100|AGE}{ years old|}"]
}, function(req, res) {
res.say('Your name is ' + req.slot('NAME') + ' and you are ' + req.slot('AGE') + ' years old');
});
app.intent('AgeIntent', {
"slots": { "AGE": "NUMBER" },
"utterances": ["My age is {1-100|AGE}"]
}, function(req, res) {
res.say('Your age is ' + req.slot('AGE'));
});
module.exports = app;
This results in:
serving static content from: /home/ec2-user/Tinkering/xAlexa/public_html
loading server-side modules from: /home/ec2-user/Tinkering/xAlexa/server
loaded /home/ec2-user/Tinkering/xAlexa/server/login.js
loading apps from: /home/ec2-user/Tinkering/xAlexa/apps
/home/ec2-user/Tinkering/xAlexa/apps/hello_world/node_modules/alexa-app/index.js:491
express.post(endpoint, function(req, res) {
^
TypeError: undefined is not a function
at Object.express (/home/ec2-user/Tinkering/xAlexa/apps/hello_world/node_modules/alexa-app/index.js:491:13)
at /home/ec2-user/Tinkering/xAlexa/node_modules/alexa-app-server/index.js:122:11
at Array.forEach (native)
at Object.self.load_apps (/home/ec2-user/Tinkering/xAlexa/node_modules/alexa-app-server/index.js:82:30)
at Object.self.start (/home/ec2-user/Tinkering/xAlexa/node_modules/alexa-app-server/index.js:188:12)
at Function.appServer.start (/home/ec2-user/Tinkering/xAlexa/node_modules/alexa-app-server/index.js:295:21)
at Object.<anonymous> (/home/ec2-user/Tinkering/xAlexa/server.js:3:31)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Sorry, I must be missing something else.
Can you put this project on Github pls, I can take a look.
I ended up going with lambda. This is more of a research project, so I can stick with that for now. If I need to I'll pick this back up and put it on github per your request. Thanks for your help!
I had the same problem, and it was because I was symlinking the package.json
file in the app folder to the parent alexa-app-server folder (still not sure how to use only one package.json
file). At some point, I had ran npm install
from the app directory, so the app was trying to use old versions of alexa-app/-server from the node_modules of that directory. To fix, just wipe node_modules
from the app directory.
Ok, so I have alexa-app-server server.js like so:
And then in
./apps/hello_world/index.js
, I have:But when I start the server I get this stack trace complaining about express.post:
I tried installing express then updating
./apps/hello_world/index.js
to be:And this starts the server, but the app does not load:
Any ideas?