GV14982 / async-airtable

A lightweight npm package to handle working with the Airtable API.
https://www.npmjs.com/package/asyncairtable
MIT License
54 stars 5 forks source link

SyntaxError: Cannot use import statement outside a module #83

Open rhwinter opened 2 years ago

rhwinter commented 2 years ago

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 commented 2 years ago

I have the same issue.

rhwinter commented 2 years ago

I guess for now the solution is npm install asyncairtable@2.1.0

cfab commented 2 years ago

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