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

229
Visualizações
Npm package working locally but not with from npm repo with npx

I've created a new cli based node application and published it to npm.

When I run the package locally with:

npm run build

which just runs rm -rf lib && tsc -b

and then

npm link
npx my-package arguments

it is working fine.


But when I run directly from npm (not locally and after removing the local one)

npx my-package arguments

It gives me an import error.

internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/usr/local/lib/node_modules/my-package/lib/src/cli/lex.js' imported from /usr/local/lib/node_modules/my-package/lib/src/index.js

note sure why?

Problematic code

#!/usr/bin/env node
import { command } from './cli/lex.js';
command.parse(process.argv);

Folder Structure

lib
 - src
 - - index.js
 - - cli
 - - - lex.js
 

Output of ls -l /usr/local/lib/node_modules/my-package/lib/src/cli

-rw-r--r--  1 root  wheel  1893 Oct 26  1985 cli.js.map
-rw-r--r--  1 root  wheel   402 Oct 26  1985 lex.js.map
-rw-r--r--  1 root  wheel  2000 Oct 26  1985 parse.js.map

There are map files but not the actual js

Here is the file in the project (github) if required.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After hours of debugging and pushing useless path versions if I found out that it was due to this in my .gitignore

*.js

Due to this the js files generated were not being pushed to npm and thus the error.

about 4 years ago · Juan Pablo Isaza Relatório
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