Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

333
Vistas
Error exporting my TypeScript NPM package

I'm trying to import my NPM package I made, but I keep getting this error:

Error: Cannot find module '/Users/…/project/node_modules/@my-package/lib/rehype-toc' imported from /Users/.../project/node_modules/@my-package/lib/index.js.

For the life of me, I cannot figure out why I'm getting this error. Everything seems like it should work since my lib/rehype-toc file is exporting a function and the file is actually there inside the lib folder. It's not missing.

Importing my package in NextJS

import rehypeToc from '@my-package';

Package Setup

package.json

// ...
"main": "lib/index.js",
"type": "module",
"types": "lib/index.d.ts",
"files": [
  "lib"
],

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["ES2020"],
    "module": "ES2020",
    "moduleResolution": "node",

    "outDir": "lib",
    "sourceMap": true,
    "declaration": true,

    "typeRoots": [
      "node_modules/@types",
      "src/typings"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "test/**/*.js"
  ]
}

lib/index.js

import { toc } from "./rehype-toc";
export * from "./types";
export { toc };
// Export `toc` as the default export
export default toc;
//# sourceMappingURL=index.js.map

lib/index.d.ts

import { toc } from "./rehype-toc";
export { CssClasses, InsertPosition, Options } from "./options";
export * from "./types";
export { toc };
export default toc;

lib/rehype-toc.js

import { createTOC } from "./create-toc";
import { customizationHooks } from "./customization-hooks";
import { findHeadings } from "./find-headings";
import { findMainNode } from "./find-main-node";
import { insertTOC } from "./insert-toc";
import { NormalizedOptions } from "./options";

export function toc(opts) {
  // ...
}

Any help would be greatly appreciated.

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda