Skip to content

[regression-1.41.2] error: 'import', and 'export' cannot be used outside of module code #22811

@rracariu

Description

@rracariu

Importing a .js file from node_modules is automatically treated as common js.
In Deno 1.42.1 this was not the case.

Something like:

import * as foo from 'node_modules/my_package/my_module.js'

Will result in:

error: 'import', and 'export' cannot be used outside of module code

This error goes away if you rename that module to my_module.mjs

Note: Deno is configured with the unstable "byonm" flag.

deno 1.41.2 (release, aarch64-apple-darwin)
v8 12.1.285.27
typescript 5.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidwhat appeared to be an issue with Deno wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions