What is the link command in npm?

0

The question is the same as the title: What is the link command in npm?

Some react native modules request that the command npm link react-native-nome-do-modulo

And sometimes some modules stop working when I do this.

What is the true function of this command?

    
asked by anonymous 13.02.2018 / 01:29

2 answers

2

When you install a third-party package in your project, you need to point to the dependencies of these

For android , for example, these usually have to be listed in android/app/build.gradle and android/settings.gradle in addition to indicating the package in android/app/src/main/java/com/<seuprojeto>/MainApplication.java

This is all necessary so that at the time you set up the project, you can find the files needed for the operation of that package in your project.

But instead of indicating the path manually, the command npm link ... was used to apply the dependencies automatically

But today this command is no longer used and has been replaced by react-native link

    
14.02.2018 / 20:10
0

My Environment:

~/pega-usuarios
~/pega-usuarios/index.js       #retorna um array de usuarios
~/pega-usuarios/package.json   #"name":"pega"  #pega será usado para npm link pega.

If I give a npm link inside this folder, a global symbolic link will be created in {prefix}/lib/node_modules/<package>

Now I'm on my site and I want to get this list of users

~/usuarios
~/usuarios/index.js
~/usuarios/package.json      #

I want to be able to do this,

Reason for this, when you make a change in npm link pega it will also be done in pega

Observations

-When you require a globally linked packet, such as ~/pega-usuarios/ , it does not go to dependencies in ~/pega-usuarios it goes only to ~/usuarios/node_modules/pega

Source
link

    
13.02.2018 / 02:50