How to install connect for use as an executable with bash - bash

I've installed Connect via npm but can't access it's executable, how do I install it?
$ node -v
v0.4.7
$ npm -v
1.0.6
$ express -v
2.3.4
$ connect -v
-bash: connect: command not found
Update
I've added it to the $PATH:
$ npm link connect
../../node_modules/connect -> /Users/Alfred/local/lib/node_modules/connect
export PATH=$HOME/local/lib/node_modules/connect:$PATH' >> ~/.bash_profile
$PATH
-bash: /Users/Alfred/.rvm/gems/ruby-1.9.2-p0/bin:/Users/Alfred/.rvm/gems/ruby-1.9.2-
p0#global/bin:/Users/Alfred/.rvm/rubies/ruby-1.9.2p0/bin:/Users/Alfred/.rvm/bin:/Users
/Alfred/local/lib/node_modules/connect:/Users/Alfred/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/usr/local/bin:/usr/local/lib:/usr/local/git/bin:/ usr/X11/bin: No such file or
directory
But it still don't work...

node as a bash executable runs you a node interpreter.
npm as a bash executable allows you to use npm to install programs.
express as a bash executable sets up boilerplate code for.
connect as a bash executable does nothing. This is normal.
All modules do nothing by default. npm, node and express are exceptions.
Note that npm has some kind of API to find the version of connect

Related

Could not run installed asdf plugins (elixir/node) even if the plugins has been installed

I've installed asdf successfully and I could install the plugin with asdf. but when it is time to run the plugin, the plugin itself is unavailable from the terminal even though the asdf list told me that the plugin (package) is in there (installed).
ubuntu#767c4736d92a:/app$ asdf list
elixir
1.14.3-otp-25
erlang
25.2.2
nodejs
*16.17.0
postgres
*15.1
ubuntu#767c4736d92a:/app$ elixir
bash: elixir: command not found
ubuntu#767c4736d92a:/app$ npm
bash: npm: command not found
ubuntu#767c4736d92a:/app$ node
bash: node: command not found
ubuntu#767c4736d92a:/app$
The problem is that the shell doesn't know where to find the plugins that you have installed through asdf, that is why it is not letting you be able to run the commands of the plugins that you have installed.
You can resolve this issue by adding the asdf shims directory to your shells PATH environment variable.
The command to add the directory to PATH can be looked up on Google.

How to set up WSL toolchain in CLion to behave like interactive WSL?

I've got a Debian WSL2 install that I'm using to write some cross platform C code. As part of the CMake setup, I'm calling a non-global install of npm (which I installed using nvm). This works fine when running interactively, but when run from the CLion Run configuration, it isn't aware of the NVM install - likely because it's not sourcing the bash_profile before running. How can I get a non-interactive shell to run interactively in this context?
To correctly find your NPM install through NVM, you can use a combination of sudo and source. The key is to always source nvm.sh before attempting to use anything installed by npm
In your CMake
add_custom_command(
COMMAND sudo -u <your user> /path/to/script.sh
...
)
In your build script, /path/to/script.sh
#!/bin/bash
# other init stuff
# before your first npm/nvm call
source "$HOME/.nvm/nvm.sh"
# now you can use anything installed by npm

Can't install golangci-lint locally

I'm using RHEL 8.6 and my Go version is the following:
$ go version
go version go1.18.3 linux/amd64
I'm trying to install locally golangci-lint and none of the described ways in the documentation are working.
What I tried:
First:
$ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
golangci/golangci-lint info checking GitHub for tag 'v1.46.2'
golangci/golangci-lint info found version: 1.46.2 for v1.46.2/linux/amd64
golangci/golangci-lint info installed /home/acabista/go/bin/golangci-lint
$ golangci-lint --version
bash: golangci-lint: command not found...
Second:
$ go install github.com/golangci/golangci-lint/cmd/golangci-lint#v1.46.2
$ golangci-lint --version
bash: golangci-lint: command not found...
Am I missing a step? How can I make this local installation work?
If golang-ci has properly been installed, the issue is most likely that the installation directory is not in your PATH environment variable. Calling golang-ci this way should then work:
${GOPATH}/bin/golangci-lint --version
or
/home/acabista/go/bin/golangci-lint --version
To chek what is happening exactly you can check the content of the GOPATH environment variable. Its content defines where binaries are installed when a go install like command is run.
echo $GOPATH
You need to check also what is the content of the PATH variable, this one defines in which directory the shell looks for binary to execute:
echo $PATH

Attempting to use Sanity.io CLI results in 'zsh: command not found'

I am having a problem running Sanity's CLI. I have installed the CLI with npm install -g #sanity/cli which works without a problem, and everything is installed correctly (as far as I can tell).
However, trying to use any of their CLI instructions, such as sanity init, I get this error message:
zsh: command not found: sanity
I am using npm version 6.14.11 and node version v14.16.0.
I've also been noticing a few random commands return the same zsh: command not found for various packages.
with npx it works
npx #sanity/cli init
#user1934428 is right.
I just change in the command "sanity ..." to "usr/local/Cellar/node/16.3.0/lib/node_modules/#sanity/cli/bin/sanity ..." and it worked
I had a similar problem on my mac which was caused by not installing sanity globally.
Go to your terminal and enter:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Enter your password then install sanity globally
npm install -g ng
This should solve the issue and sanity commands should work too.

express command not found in bash after installing it with npm

just installed new ubuntu vm to test around with node
installed things in this order:
node
mongodb-server
npm
express
mongoose
now, trying to create a new app i noticed express cannot be used in the shell.
express -v returns
express: command not found
i installed npm like this
curl http://npmjs.org/install.sh | sudo sh
and i installed express this way
npm install express
any ideas?
Starting from express 4.00 you also need to install express generator with:
npm install -g express-generator
Only after this will you be able to run express as a command!
For confirmation see: ExpressJS.com - Migrating to Express 4
npm install express -g
You need to install it globally.
Npm 1.0 installs modules locally by default. So the bash executable lives in /node_modules/bin/. You can add that folder to PATH or you can just install express globally so that it's picked up by PATH
I had this problem and was installing node via Homebrew. The problem was being caused by Homebrew.
So I did:
brew uninstall node
and then installed node using the installer on the nodejs.org site.
Then I ran:
npm install -g express
And voila no problems.
With the release of Express 4.0.0 it looks like you need to do sudo npm install -g express-generator.
EDIT 2017-06-29: this answer is 6+ years old, but still gets votes/traffic. Instead (for any new users with problems) I'd trust both NODE_PATH official doc and its corresponding bit about REPL usage before this answer.
Quite similar to this issue, node was not finding my global express install, so a require('express') statement would fail.
What fixed this for me, when a global install wasn't being picked up by node was making sure NODE_PATH env. variable was is set correctly.
On Ubuntu 11.04, with node version 0.5.0-pre, the paths me were:
NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node
So, to clarify you might want to export the above env. variable, or you can just test the above values out by doing:
NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node node ./you_app.js
I had to do a combination of things:
From node.js modules path:
echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.bash_profile && . ~/.bash_profile
This sets the file path in bash profile (can be viewed using nano .bash_profile
Slightly modified from Raynos (above) since I needed sudo:
sudo npm install express -g
Slightly modified from Fazi (above) since I needed sudo:
sudo npm install -g express-generator
TEST YOUR APPLICATION:
run `DEBUG=myapp:* npm start`
Ref: http://expressjs.com/en/starter/generator.html
IF you are running windows:
export NODE_PATH="C:\Users\IMarek\AppData\Roaming\npm\node_modules"

Resources