Import ESM module #3620
-
Package versionNode.js and npm versionSample Code (to reproduce the issue)
BONUS (a sample repo to reproduce the issue)Install the package I try to import the above package. But it gives me the error require() of ES Module ......\node_modules\clipboardy\index.js from .......app\Controllers\Http\RobotsController.ts not supported.
Instead change the require of index.js in .....app\Controllers\Http\RobotsController.ts to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> ......app/Controllers/Http/RobotsController.ts:9
4| import axios from 'axios';
5| import https from 'https';
6| import robot from 'robotjs';
7| import {keyboard, Key} from '@nut-tree/nut-js';
8| import execa from 'execa';
> 9| import clipboard from 'clipboardy'; I have tried dynamic import, async import, sync import. nothing works and i cant find anything on import ESM into adonis. It works with other node projects. Just not with adonis |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
See here for more informations : https://news.adonisjs.com/issues/round-up-2021-and-the-future-848097
In the meantime, you can just use the v2.3.0 version of clipboardy. |
Beta Was this translation helpful? Give feedback.
-
In my case I had the same problem in node js with node-fetch. I solved it using the dynamic import:
|
Beta Was this translation helpful? Give feedback.
See here for more informations : https://news.adonisjs.com/issues/round-up-2021-and-the-future-848097
In the meantime, you can just use the v2.3.0 version of clipboardy.