handler.js
import {login} from 'userLogin';
module.exports.hello = async (event, context) => {
return {
statusCode: 200,
body: JSON.stringify({
message:userLogin.login("kasun") ,
input: event,
}),
};
// Use this code if you don't use the http event with the LAMBDA-PROXY integration
// return { message: 'Go Serverless v1.0! Your function executed successfully!', event };
};
userLogin,js
export function login(userName){
return userName;
}
.babelrc
{
"plugins": ["source-map-support", "transform-runtime"],
"presets": [
["env", { "node": "8.10" }],
"stage-3"
]
}
我尝试使用AWS Lambda和Node js创建一个项目。我试图做的是我想调用一个名为hello的函数,但是当我调用该函数时会出现以下错误
ERROR in ./handler.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'babel-plugin-transform-runtime' from 'C:\Users\Kasun\Desktop\adminApp'
at Function.module.exports [as sync] (C:\Users\Kasun\Desktop\adminApp\node_modules\resolve\lib\sync.js:58:15)
at resolveStandardizedName (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\files\plugins.js:101:31)
at resolvePlugin (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\files\plugins.js:54:10)
at loadPlugin (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\files\plugins.js:62:20)
at createDescriptor (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-descriptors.js:154:9)
at items.map (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
at Array.map (<anonymous>)
at createDescriptors (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
at createPluginDescriptors (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-descriptors.js:105:10)
at plugins (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-descriptors.js:40:19)
at mergeChainOpts (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-chain.js:319:26)
at C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-chain.js:283:7
at buildRootChain (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\config-chain.js:120:22)
at loadPrivatePartialConfig (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\partial.js:85:55)
at Object.loadPartialConfig (C:\Users\Kasun\Desktop\adminApp\node_modules\@babel\core\lib\config\partial.js:110:18)
at Object.<anonymous> (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:140:26)
at Generator.next (<anonymous>)
at asyncGeneratorStep (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:3:103)
at _next (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:5:194)
at C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:5:364
at new Promise (<anonymous>)
at Object.<anonymous> (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:5:97)
at Object._loader (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:220:18)
at Object.loader (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:56:18)
at Object.<anonymous> (C:\Users\Kasun\Desktop\adminApp\node_modules\babel-loader\lib\index.js:51:12)