Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

SyntaxError: Cannot use import statement outside a module #83

Open
rhwinter opened this issue Dec 13, 2021 · 3 comments
Open

SyntaxError: Cannot use import statement outside a module #83

rhwinter opened this issue Dec 13, 2021 · 3 comments

Comments

@rhwinter
Copy link

rhwinter commented Dec 13, 2021

Describe the bug

There's an issue when trying to use the module, it just doesn't work. Am I getting something very wrong?
I used version 2.1.0 without any problems and now I tried 2.3.1 and it just won't work.

To Reproduce
Steps to reproduce the behavior:

  1. create an empty folder and cd into it
  2. npm install asyncairtable
  3. add import { AsyncAirtable } from 'asyncairtable'; to a blank index.js
  4. node index.js

It will throw the following error:

/.../node_modules/asyncairtable/lib/asyncAirtable.js:10
import buildOpts from './buildOpts';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (.../index.js:1:23)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)

Expected behavior
The script should run without any output.

Node versions

Tested with Node 16.6.1 and 17.2.0 (using nvm)
Npm version 7.20.3

@vrbajaroslav
Copy link

I have the same issue.

@rhwinter
Copy link
Author

I guess for now the solution is npm install [email protected]

@cfab
Copy link

cfab commented Apr 23, 2022

This might be useful: "asyncairtable doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix." ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants