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

204
Visualizações
Is it possible to use the package name in a local package import?

I'm building a package and I wanted to build tests only if a certain function of the same local package is called. I don't want to get too much into the details but I am traversing the code with a Babel plugin to look for a specific module import to perform some actions.

The problem is that when I import this function I use locale paths, like this:

import { myFunction } from './';

I would like instead to have something like:

import { myFunction } from 'my-real-package-name';

I tried to install my package locally but now I am getting this error when trying to build:

error TS5055: Cannot write file '/my-real-package-name/lib/index.d.ts' because it would overwrite input file.

I could always check if the import is from ./ or my-real-package-name but I would prefer to just use my-real-package-name since it's safer to avoid unexpected issue.

Is there another way to achieve this?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think what you're looking for is npm link or yarn link depending on your package manager.

From npm documentation page:

This is handy for installing your own stuff, so that you can work on it and test iteratively without having to continually rebuild.

Package linking is a two-step process.

First, npm link in a package folder with no arguments will create a symlink in the global folder {prefix}/lib/node_modules/ that links to the package where the npm link command was executed. It will also link any bins in the package to {prefix}/bin/{name}. Note that npm link uses the global prefix (see npm prefix -g for its value).

Next, in some other location, npm link package-name will create a symbolic link from globally-installed package-name to node_modules/ of the current folder.

For example:

cd ~/projects/node-redis    # go into the package directory
npm link                    # creates global link
cd ~/projects/node-bloggy   # go into some other package directory.
npm link redis
about 4 years ago · Santiago Trujillo 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