Amazon web services aws cognito中缺少一个模块:errorMessage";:&引用;找不到模块'/库/浏览器加载程序

Amazon web services aws cognito中缺少一个模块:errorMessage";:&引用;找不到模块'/库/浏览器加载程序,amazon-web-services,amazon-cognito,aws-cognito,Amazon Web Services,Amazon Cognito,Aws Cognito,我试图在我的项目中使用cognito,但当我按照所有必要的设置进行操作时,我无法运行它,在我的lamda测试控制台中,我得到以下错误: { "errorMessage": "Cannot find module './lib/browser_loader'", "errorType": "Error", "stackTrace": [ "Function.Module._load (module.js:417:25)", "Module.require (module.js:

我试图在我的项目中使用cognito,但当我按照所有必要的设置进行操作时,我无法运行它,在我的lamda测试控制台中,我得到以下错误:

{
  "errorMessage": "Cannot find module './lib/browser_loader'",
  "errorType": "Error",
  "stackTrace": [
  "Function.Module._load (module.js:417:25)",
  "Module.require (module.js:497:17)",
   "require (internal/module.js:20:19)",
   "Object.<anonymous> (/var/task/index.js:3651:1)",
    "__webpack_require__ (/var/task/index.js:20:30)",
   "webpackUniversalModuleDefinition (/var/task/index.js:149:28)",
   "Object.<anonymous> (/var/task/index.js:156:3)",
   "__webpack_require__ (/var/task/index.js:20:30)",
   "Object.<anonymous> (/var/task/index.js:75:18)"
  ]
 }
"errorMessage": "Cannot find module './lib/browser_loader'"
这是我的webpack.config:

var path = require("path");
var DIST_DIR = path.resolve(__dirname, "dist");
module.exports = {
// Example setup for your project:
// The entry module that requires or imports the rest of your project.
// Must start with `./`!
entry: './',
// Place output files in `./dist/my-app.js`
output: {
    path: DIST_DIR,
    filename: 'index.js'
},
module: {
    noParse: [
        /aws\-sdk/,
    ],
    loaders: [
        {
            test: /\.json$/,
            loader: 'json'
        }
    ]
}
 };
所以现在我假设我的代码应该准备好转换了。这是我的密码:

var AWSCognito = require('amazon-cognito-identity-js/dist/amazon-cognito-
 identity'); 


 exports.handler = function (event, context, callback) {
     registerUset();
     callback(null, "some success message");

 }


 var registerUset = function () {

 }
正如您所看到的,它只是一个简单的java脚本代码,没有任何内容。现在,当我执行:npm run build时,我看到了编译的js文件,并且没有得到任何错误。 但是,当我压缩js和node module文件夹并在lambda控制台中上载和测试它时,我得到以下错误:

{
  "errorMessage": "Cannot find module './lib/browser_loader'",
  "errorType": "Error",
  "stackTrace": [
  "Function.Module._load (module.js:417:25)",
  "Module.require (module.js:497:17)",
   "require (internal/module.js:20:19)",
   "Object.<anonymous> (/var/task/index.js:3651:1)",
    "__webpack_require__ (/var/task/index.js:20:30)",
   "webpackUniversalModuleDefinition (/var/task/index.js:149:28)",
   "Object.<anonymous> (/var/task/index.js:156:3)",
   "__webpack_require__ (/var/task/index.js:20:30)",
   "Object.<anonymous> (/var/task/index.js:75:18)"
  ]
 }
"errorMessage": "Cannot find module './lib/browser_loader'"

完整的堆栈张贴在帖子的开头。对我来说这毫无意义。这是aws的错误还是我遗漏了什么?

我找到了解决问题的方法,以防任何人遇到同样的问题:

感谢:

因此,基本上我需要使用babel和json作为加载程序,因此解决方案的关键部分是:

module: {
 loaders: [
   {
     test: /\.js$/,
     exclude: /node_modules/,
     loader: 'babel',
     query: {
     presets: ['es2015'],
       plugins: ['syntax-flow', 'transform-flow-strip-types']
      }
    },
     {
      test: /\.json$/,
      loader: 'json'
     }
   ]
   }