async-airtable icon indicating copy to clipboard operation
async-airtable copied to clipboard

SyntaxError: Cannot use import statement outside a module

Open rhwinter opened this issue 3 years ago • 3 comments

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

rhwinter avatar Dec 13 '21 18:12 rhwinter

I have the same issue.

vrbajaroslav avatar Dec 13 '21 19:12 vrbajaroslav

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

rhwinter avatar Dec 15 '21 10:12 rhwinter

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." ;-)

cfab avatar Apr 23 '22 09:04 cfab