admin管理员组

文章数量:1303668

I'm caught in the hell of Node/JavaScript versions. I'm getting the error, " The requested module '../../index.mjs' does not provide an export named 'handler'"

My calling file is like this.

import { handler } from '../../index.mjs'
handler(event, null, null);

But index.mjs contains:

export const handler = async (event, context) => {
    var test = 0;
}

I've also tried

exports.handler = handler;

and

const _handler = handler;
export { _handler as handler };

I've tried .mjs, and .js file extensions. My package.json is set to "type": "module"

EDIT: This also doesn't work.

export async function handler(event, context) {
    var test = 0;
}

本文标签: nodejsThe requested module 39indexmjs39 does not provide an export named 39handler39Stack Overflow