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

207
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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