Yarn global install of private module - react-native

I am trying to install a module globally with yarn.
I typed the following command:
yarn global add react-native-rename
and then I find it in the yarn global directory, and I am able to call it directly since the directory is included in the path.
But if I try to do the same thing with the same cloned repository hosted on my gitlab:
yarn global add git+ssh://git#git.company.info:mobile/react-native-rename.git
the installation goes fine but the binary is not present into the folder.
yarn global list
shows the binaries as installed but I am unable to find it, neither looking for it using which react-native-rename.
Any idea?

Could you try adding this to your .bashrc or .zshrc?
export PATH="$(yarn global bin):$PATH"
Yarn Global docs
https://classic.yarnpkg.com/en/docs/cli/global/
FYI: Locations on my mac
Executable: /usr/local/bin
Location of downloaded code: ~/.config/yarn/global/node_modules
Could you check these two directories?

Related

NPX create-react-app creating other folders

So whenever i use
npx create-react-app my-app
it generates outside the folder "my-app" a lot of others folders such as _locks, _npx, _cacache and a json file named anonymous-cli-metrics.
I tried changing the cache location, but I couldn't do it, I want to use the command without creating these files does anyone know how to solve it?
I've also had this same problem. You should install your nodejs on your c:/ directory. Uninstall nodejs and remove cache files and remove the PATH variable and reinstall it in your C:/ directory.
Another possible problem is with chocolatey, if you've installed along with nodejs you should remove that also and do a fresh install on your root directory
Or try setting yout npm cache to,
npm config set cache C:\cache

Command not found after installing #vue/cli

I npm installed #vue/cli with npm install -g #vue/cli. but when I try the vue command I get -bash: vue: command not found. I added export PATH="/usr/local/Cellar/node/11.2.0/lib/node_modules/#vue/cli/bin:$PATH" to my bash profile and when I echo path in terminal I get
/usr/local/opt/openssl/bin:/usr/local/Cellar/node/11.2.0/lib/node_modules/#vue/cli/bin:/Users/jimmymona/.node/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Which does have the path to the vue cli in it: /usr/local/Cellar/node/11.2.0/lib/node_modules/#vue/cli/bin
I also tried sudo installing it but that didn't work either
Anyone know what the issue is?
The path is wrong. The binary resides in /usr/local/Cellar/node/11.2.0/bin rather than .../lib/....
As you'll notice, the file in the latter directory is named as vue.js, not vue.
NPM creates a symlink without the .js extension to it in the bin directory, and that's the actual binary we typically refer to.
Typically we don't use the full path in .bashrc directly (in case the npm global path changes).
Rather, it's recommended to calculate it by combining the result of npm config get prefix and /bin, i.e.
export PATH="$PATH:$(npm config get prefix)/bin"

Is there any difference between installing global packages with Yarn or NPM?

Does it matter whether you install a global package with yarn global add PACKAGE vs npm install -g PACKAGE ?
Is there any difference at all, like where files are installed?
If yes, what is it?
So yes, you are right it is different. For npm it is something like below
/Users/tarunlalwani/.nvm/versions/node/v9.2.0/lib if you are using nvm
You can get this path using
$ npm config get prefix
/Users/tarunlalwani/.nvm/versions/node/v9.2.0
Where does npm install packages?
While yarn uses other paths
Windows: %LOCALAPPDATA%/Yarn/config/global
OSX and Linux non-root: ~/.config/yarn/global
Linux if logged in as root: /usr/local/share/.config/yarn/global
How to display yarn globally installed packages?
See this thread as well
https://github.com/yarnpkg/yarn/issues/2049
This is the document about Yarn global
yarn global is a prefix used for a number of commands like add, bin,
list and remove. They behave identically to their normal versions
except that they use a global directory to store packages. The global
command makes executables available to use on your operating system
and this is the document about npm install global mode
In global mode (ie, with -g or --global appended to the command), it
installs the current package context (ie, the current working
directory) as a global package.
I think there is no difference between them. Install a package as a global useful for developer tooling that is not part of any individual project but instead is used for local commands

in npm Windows version, global installation seems not working

Using npm 3.10.10 on Windows, global installation is not storing modules under "<\user>\AppData\Roaming\npm". It is actually installing under <\working directory>\.node_modules_global.
By command "npm config ls -l --global", it shows "prefix" is overridden by user configuration in .npmrc. Then, I find in <\node installation dir>\node_modules\npm\npmrc" file:
prefix=${APPDATA}\npm
Is it a bug? Shouldn't global modules be installed somewhere available to the entire machine? Otherwise, .node_modules_global folders could be created everywhere on the machine now and "global" doesn't work as "global".
I figured it out by my own. There is an unexpected user config file under C:\User\.npmrc, which sets up a customized "prefix=.node_modules_global". That setting overrides builtin config <\node installation dir>\node_modules\npm\npmrc.

Installing Bower globally using npm

I am trying to install Bower globally and it is installed in the directory of
C:\Users\{{user}}\AppData\Roaming\npm\node_modules\bower
I have added the system path of Path and NODE_PATH to that of above, however when running bower, it still cant find the modules.
the prefix of npm-config is:
C:\Users\{{user}}\AppData\Roaming\npm
however later within the the list it states it as
"C:\Program Files (x86)\nodejs" (overridden)
Ive run out of ideas of what it could be,
If you using npm, which looks like you are, then use the global flag (run as admin)
npm install -g bower
Sometimes another version or just a wrong path is referenced in the npm config file instead of the installed version.
This may cause node/npm to misplace global modules.
To check and fix:
In cmd line type: npm config list
You should get a list of configuration values, one of them is prefix.
Make sure the path in prefix is the same path (only without node.exe) as the actually installed node.exe path.
(this path is listed further down as node bin location)
If it's not, change it:
Either in the config file (in your user folder, named .npmrc)
Or, via cmd line: npm config set prefix "C:\Program Files\nodejs" (change path if needed)
Reinstall the module/package you tried to install, don't forget -g for global.