Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

332
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda