Skip to content

Version 4 in Node complains about "Cannot use import statement outside a module" #619

@perivar

Description

@perivar

First of all, thanks for a very good library!

I have spent more than 5 hours trying to upgrade my typescript node project to work after the changes between version 3 and 4, and have at this moment given up and rolled back to version 3.

The error given when running the program is:
SyntaxError: Cannot use import statement outside a module:

The error happens in:
/node_modules/chord-symbol/src/index.js:1
import './typedefs';
^^^^^^
SyntaxError: Cannot use import statement outside a module

I tried following several tutorials to see if setting typescript compiling to esnext and setting type to "module" in package.json would work but had to give up after hours of errors.
I also tried to see if it was only the first import line that stopped this from working, but then it fails on the second import in the same index.js file, so for some reasons all "imports" have stopped working.

I'm noe sure what changed between version 3 and 4 that made a standard typescript node project stop working, but I can confirm that chord-symbol version 4 works perfectly in react native expo.

Here are some tutorials I tried, but none of them helped.
https://stackoverflow.com/questions/71929951/typescript-syntaxerror-cannot-use-import-statement-outside-a-module-side-file
https://stackoverflow.com/questions/74766930/syntaxerror-cannot-use-import-statement-outside-a-module-in-nodejs-typescript

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions