ปัญหางาน Node.js Alexa
ฉันกำลังเขียนโค้ด Node.js Alexa Task ผ่าน AWS Lambda และฉันพยายามโค้ดฟังก์ชันที่รับข้อมูลจาก OpenWeather API และแยกวิเคราะห์เป็นตัวแปรที่เรียกว่าweather. รหัสที่เกี่ยวข้องมีดังนี้:
var request = require('request');
var weather = "";
function isBadWeather(location) {
      var endpoint = "http://api.openweathermap.org/data/2.5/weather?q=" + location + "&APPID=205283d9c9211b776d3580d5de5d6338";
      var body = "";
      request(endpoint, function (error, response, body) {
            if (!error && response.statusCode == 200) {
                  body = JSON.parse(body);
                  weather = body.weather[0].id;
            }
      });
}
function testWeather()
{
      setTimeout(function() {
      if (weather >= 200 && weather < 800)
            weather = true;
      else
            weather = false;
      console.log(weather);
      generateResponse(buildSpeechletResponse(weather, true), {});
      }, 500);
}
ฉันใช้ตัวอย่างข้อมูลนี้นับครั้งไม่ถ้วนใน Cloud9 และ IDE อื่น ๆ และดูเหมือนว่าจะทำงานได้อย่างไม่มีที่ติ อย่างไรก็ตามเมื่อฉัน zip ลงในแพ็คเกจและอัปโหลดไปยัง AWS Lambda ฉันได้รับข้อผิดพลาดต่อไปนี้:
{
    "errorMessage": "Cannot find module '/var/task/index'",
    "errorType": "Error",
    "stackTrace": [
        "Function.Module._load (module.js:276:25)",
        "Module.require (module.js:353:17)",
        "require (internal/module.js:12:17)"
    ]
}
ฉันค้นหาบทความนับไม่ถ้วนและติดตั้งโมดูล -js คำขอและโมดูลโหนดอื่น ๆ อีกมากมายที่ควรทำให้โค้ดนี้ทำงาน แต่ดูเหมือนจะไม่มีอะไรแก้ไขปัญหานี้ได้ นี่คือไดเร็กทอรีของฉันในกรณี:
- planyr.zip
   - index.js
   - node_modules
   - package.json
ไม่มีใครรู้ว่าปัญหาอาจเกิดขึ้นได้อย่างไร? ขอบคุณมากล่วงหน้า


START RequestId: 46c71292-debf-11e6-a013-1be2c415a9c1 Version: $LATEST Unable to import module 'index': Error at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) END RequestId: 46c71292-debf-11e6-a013-1be2c415a9c1 REPORT RequestId: 46c71292-debf-11e6-a013-1be2c415a9c1 Duration: 55.76 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 16 MB