Questions tagged [esmodules]

57 questions
8
votes
1 answer

Use d3 in an commonjs npm module

I am creating a private npm package to visualize the structure of a Vuejs project. d3 seems to be on of the best choices for a visualization, but I have problems to include it in my script. In the package.json I defined my script under the bin…
link
  • 491
  • 1
  • 4
  • 13
6
votes
2 answers

Cannot import package in AWS lambda with Nodejs14.x ES module

I have a layer where the path of node_modules is nodejs/node14/node_modules. Using that layer, and I try to import a package in a Lambda function, say 'aws-cloudfront-sign', like this: import cfsign from 'aws-cloudfront-sign' I got error…
Lam
  • 93
  • 1
  • 2
  • 7
3
votes
0 answers

Nodejs + TS CommonJS vs Module issue for Inquirer package

When i imported inquirer i have started getting errors about CommonJS and Modules errors. So this current one suggesting my to use dynamic imports const inquirer = await import('inquirer'); then i also had to change in tscondig "module": "ES2022",…
Marius
  • 1,664
  • 2
  • 16
  • 28
3
votes
1 answer

Error: ENOENT: no such file or directory, open 'src/protos/user.proto'?

I'm creating a node.js gRPC service. I'm using the photo buff as an npm package in this service. so the proto buff package is structured as below. and I have published this package to the GitHub npm package registry. then I used it in my…
Sathya Molagoda
  • 531
  • 1
  • 6
  • 17
2
votes
0 answers

VITE Buildiing phase: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite-plugin-commonjs'

I'm trying to dpeloy my first vite project but i'm getting the following error: 9:32:18 AM: $ npm run build 9:32:18 AM: > entertainment-app@0.0.0 build 9:32:18 AM: > vite build 9:32:18 AM: failed to load config from…
2
votes
0 answers

How to divide gulp tasks into multiple .ts files?

I've tried to setup Gulpfile configuration only with Typescript. Created in project's root folder named gulpfile.ts with index.ts: import { task } from 'gulp'; import { clearBuild } from './tasks/clear-build'; task('build',…
2
votes
1 answer

Are Native Node Absolute (ie. Root-Relative) Paths Possible With ES Module Named Imports?

Normally in Node one can useNODE_PATH=./src" to make it so that instead of: import { foo } from '../../../bar' You can just do: import { foo } from 'src/bar' However, that only works if you use the esm package (ie. node -r esm): NODE_PATH doesn't…
machineghost
  • 33,529
  • 30
  • 159
  • 234
2
votes
3 answers

Getting error when importing fontawesome icons

I'm trying to build a simple website using Astro, it runs perfectly fine when using astro dev but I can't build the website using astro build because this happens: The error I'm getting: error Named export 'faGithub' not found. The requested…
Uri
  • 31
  • 6
2
votes
2 answers

Using ES Module packages in Azure Typescript Function

I am unable to use the package p-map in my Azure Function. I get the following error: Worker failed to load function: 'serverless' with function id: ''. Result: Failure Exception: Worker was unable to load function serverless: 'Error…
2
votes
1 answer

Dynamically load React component library from URL?

I am working on documentation tool for Typescript library. The idea is to leverage parcel's watch mode to continuously build the library, and use the same in a pre-built documentation app. For the same I need to load a module library (built in…
sangupta
  • 2,396
  • 3
  • 23
  • 37
2
votes
3 answers

How to import via a URL using ES modules?

I want to import a library like axios directly from a URL and use it. I don't want to add it as a script which adds axios to the window object (as shown below). index.html
anon
1
vote
1 answer

How can I solve Unexpected Token 'export' for Jest Testing

I am writing tests for a React App. While running my tests, I'm getting this error.Error Message Grid is being exported from "node_modules/gridjs/dist/index.d.ts" Export file Here is my jest.config.js module.exports = { rootDir: "src", …
Nick2Legit
  • 11
  • 1
1
vote
1 answer

ESmodules: The requested module '****' does not provide an export named '****'

Newbie question here. I have this problem using ESmodules. SyntaxError: The requested module './esModules.js' does not provide an export named 'add'. I do have the "Type": "modules" in my package.json My code: // index.js import add from…
Fonsecar
  • 21
  • 4
1
vote
0 answers

Typescript add custom type definitions for esm library from commonjs project

When using commonjs libraries it is possible to extend/overwrite their type, for example: declare module 'ramda' { function path(path: Path, obj: any): T; } But how can we do this with esm libraries? I am trying to achieve same thing with…
1
vote
0 answers

Is javascript module for browser or node

Is there a certain way to tell if a javascript module or library is meant to be used on the browser or on node/deno environment? I know that library authors can use the browser field in package.json to signal that a library depends on browser APIs…
dinika saxena
  • 101
  • 1
  • 8
1
2 3 4