Error: Package exports for ‘/app/node_modules/uuid’ do not define a valid ‘.’ target



So some ungodly reason when I implement the following snippet:

import { Listener, OrderCreatedEvent, Subjects } from '@dc_microurb/common';
import { Message } from 'node-nats-streaming';
import { queueGroupName } from './queue-group-name';
import { expirationQueue } from '../../queues/expiration-queue';

export class OrderCreatedListener extends Listener<OrderCreatedEvent> {
  subject: Subjects.OrderCreated = Subjects.OrderCreated;
  queueGroupName = queueGroupName;

  async onMessage(data: OrderCreatedEvent['data'], msg: Message) {
    const delay = new Date(data.expiresAt).getTime() - new Date().getTime();
    console.log('Waiting this many milliseconds to process the job:', delay);

    await expirationQueue.add(
      {
        orderId: data.id,
      },
      {
        delay,
      }
    );

    msg.ack();
  }
}

In particular the first argument to expirationQueue.add(), {orderId: data.id, }, I get the following error in my terminal:

[expiration-depl-5c47c7f4d5-5d68l expiration] Error: Package exports for ‘/app/node_modules/uuid’ do not define a valid ‘.’ target [expiration-depl-5c47c7f4d5-5d68l expiration] at resolveExportsTarget (internal/modules/cjs/loader.js:545:13) [expiration-depl-5c47c7f4d5-5d68l expiration] at applyExports (internal/modules/cjs/loader.js:459:14) [expiration-depl-5c47c7f4d5-5d68l expiration] at resolveExports (internal/modules/cjs/loader.js:508:12) [expiration-depl-5c47c7f4d5-5d68l expiration] at Function.Module._findPath (internal/modules/cjs/loader.js:577:20) [expiration-depl-5c47c7f4d5-5d68l expiration] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:27) [expiration-depl-5c47c7f4d5-5d68l expiration] at Function.Module._load (internal/modules/cjs/loader.js:785:27) [expiration-depl-5c47c7f4d5-5d68l expiration] at Module.require (internal/modules/cjs/loader.js:956:19) [expiration-depl-5c47c7f4d5-5d68l expiration] at require (internal/modules/cjs/helpers.js:74:18) [expiration-depl-5c47c7f4d5-5d68l expiration] at Object. (/app/node_modules/bull/lib/timer-manager.js:4:14) [expiration-depl-5c47c7f4d5-5d68l expiration] at Module._compile (internal/modules/cjs/loader.js:1063:30) [expiration-depl-5c47c7f4d5-5d68l expiration] [nodemon] app crashed – waiting for file changes before starting…

I upgraded my Node version to v14.16.1.

Answer

This is most likely a Node issue.

It has already happen in the past with uuid. An issue regarding node v13 also have been opened back then, to report a similar problem.

Even tho it’s not a durable solution, try downgrading your Node version and open a ticket on the uuid Github repository.



Source: stackoverflow