Skip to content

Claudia with Node 14 and ES6 #237

@oakleaf

Description

@oakleaf

Since Lambda now supports Node14, it makes sense to support ES6 modules? Maybe Im doing something crazy here, but I just installed latest Claudia.js on my macOS M1, it seems to be homebrewed.

  • Expected behaviour:
    Be able to create / use Claudia with ES6 modules/development

  • What actually happens:
    When running "claudia create --region eu-north-1 --handler index.handler", I get errors about not using ES5 structure

Console:

bash-3.2# claudia create --region eu-north-1 --handler index.handler
packaging files npm install -q --no-audit --production
npm WARN config production Use `--omit=dev` instead.

added 223 packages in 1s

3 packages are looking for funding
validating package
Error [ERR_REQUIRE_ESM]: require() of ES Module /private/tmp/MsKutW/hello_world-1.0.0-KAgNGL/package/index.js from /opt/homebrew/lib/node_modules/claudia/src/tasks/validate-package.js not supported.
Instead change the require of index.js in /opt/homebrew/lib/node_modules/claudia/src/tasks/validate-package.js to a dynamic import() which is available in all CommonJS modules.
    at validatePackage (/opt/homebrew/lib/node_modules/claudia/src/tasks/validate-package.js:16:15)
    at /opt/homebrew/lib/node_modules/claudia/src/commands/create.js:370:10
cannot require ./index after clean installation. Check your dependencies.
  • Link to a minimal, executable project that demonstrates the problem:
import { v4 as uuidv4 } from "uuid";

export const handler = async (e) => {
console.log("hello world");
};
  • Steps to install the project:
    In package.js, use "type": "module" to enable ES6 compability

  • Steps to reproduce the problem:
    Create an ES6 project, with "import" instead of "require", with "type": "module" in package.js. Im getting those errors above..

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions