Skip to content

Trouble integrating ES6 module in NodeJS #46

@mvermand22

Description

@mvermand22

Can you please provide a full working example of how to use the library in NodeJS?
I do not succeed in loading the library.

I always get errors such as

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by
 the default ESM loader

or
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module

This is my tsconfig.json:

{
  "compilerOptions": {
    "module": "CommonJS",
    "target": "ES6",
    "outDir": "./dist",
  },
  "exclude": [
    "node_modules"
  ]
}

I tried to add and remove the type = "module" line in package.json.
I tried

let PushBullet = require('pushbullet');

or

import {PushBullet} from 'pushbullet';

or

import {PushBullet} from '../node_modules/pushbullet/lib/pushbullet.js';

All without luck...
Please provide a working example with tsconfig.json and package.json included.

I am working on Windows 10, Node 14.0.3, npm 6.14.5.

Many thanks!

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