Home > database >  nestjs node module issue, How to use when/sequence module in nestjs
nestjs node module issue, How to use when/sequence module in nestjs

Time:10-27

I writing a code in nestjs. I am using the when module (https://www.npmjs.com/package/when) in my project.

I am importing when module as follows

import { sequence } from "when/sequence";

but when I print the sequence. it gives value as undefined. for that reason, not able to use when a module in nestjs any idea here how to import and install node module in nestjs

CodePudding user response:

Seems like when only compiles to CommonJs and AMD. Therefore, it doesn't allow the import .. from "..." syntax introduced in ES6.

You should import it is using require().

const sequence = require("when/sequence")

CodePudding user response:

import { sequence } from "when/sequence.js";

or use dynamic imports to load CJS modules:

const { default: sequence } = await import("when/sequence.js");
  • Related