katacoda command not found - linux

I'm trying to install the katacoda client. I used NPM to install it:
npm install -g katacoda-cli
The installation was successful but when I'm trying to run the katacoda help I've got the following error: command not found: katacoda. NPM installed katacoda here: /usr/local/Cellar/node/10.7.0/lib/node_modules/katacoda-cli. If I run the following: /usr/local/Cellar/node/10.7.0/lib/node_modules/katacoda-cli/bin/run help katacoda is executed correctly. I guess my problem is coming from my $PATH, which is set like this: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

You can go to one of the directories, say /usr/local/bin, and then run ln -s /usr/local/Cellar/node/10.7.0/lib/node_modules/katacoda-cli/bin/run katacoda. Then you should be able to run katacoda directly. If you don't have permissions to do so in /usr/local/bin, choose another directory where you have permissions, do the same and add the directory to your $PATH

Related

Where is the npm directory supposed to be?

The Node version is 17.7.1. When I run npm -v I get:
bash: /usr/local/bin/npm: No such file or directory
But when I run npm root -g I get:
/usr/local/lib/node_modules
Running npm list -g also gives me the same message as running npm -v.
So, where is it supposed to be and how can I fix this?
There are a few issues as to why this is occuring.
It appears that your computer cannot find the following path (below) to the npm folder, but it can find the global node_modules folder.
/usr/local/bin/npm
This may occur for a number of reasons. Luckily, there are many solutions to these issues.
1. Reinstall Node.js and npm^
The first solution is pretty obvious, and it is to reinstall Node.js and npm^.
The installation process is very simple.
If you are using only the command line, you can install Node.js using the following command. The npm command comes installed with Node.js.
$ sudo apt-get install nodejs
Or, if you want to use the installer, download and run the installer from nodejs.org.
Check the versions of Node.js and npm to see if it has worked.
$ node -v
$ npm -v
The helpful thing about reinstalling Node.js and npm in this case is that, if Node.js and npm weren't installed in the first place (highly unlikely), it will install them.
However, if they were already installed, but then something happened to the installation directory (e.g. it was renamed, moved, deleted or corrupted), then the new installation will most likely have fixed that issue.
2. Add /usr/local/bin/npm to the path (solution worked for OP)
If the first solution didn't work for you, then the next issue that might be occurring might be that /usr/local/bin/npm isn't in your path, which means that bash cannot find it.
To add npm to your path, follow the steps below.
Normally, to get the path with npm, you need to run the following command.
$ npm bin
Obviously, we have to use a workaround. But, we can just use an assumed path for where the binaries of npm are stored, which is...
/usr/local/bin/npm/bin
However, this may vary, so, to be sure that this exists, you can simply type it into the command line.
$ cd /usr/local/bin/npm
Then, you can run the ls command, and see if there are any bin folders or .sh shell scripts that might be used for the path.
$ ls
Make sure you save the binary part for later!
Open the home directory using the following command. This is because the .bashrc file is in the home directory (used in the next step).
$ cd $HOME
Open the .bashrc file using vi (or any file editor of your choice, but vi will be used in this example).
$ vi .bashrc
Then, press the i key for Insert Mode. Type the following in the file.
export PATH=/usr/local/bin/npm/bin:$PATH
In vi, press Esc, then press the following keys: :, w, q, !, Enter.
:wq!
The file is now saved and the editor is closed.
Normally, the .bashrc file is only read when you log in each time. To avoid doing that, you can force bash to read the .bashrc file and update itself. To do this, run the following command.
$ source .bashrc
The bash shell should now be restarted.
These were quite a few steps (four, but many were compressed into one), but if a situation occurred where for some reason npm wasn't adding itself to the path, this solution should fix it.
3. Denied read/write access
Another issue is that your user profile doesn't have the right permissions to read/write to usr/bin/local/npm, or you didn't give npm permissions.
The fix to this solution is very simple.
Run the npm commands you want to run using sudo.
$ sudo npm -v
$ sudo npm list -g
If you want, you can make the commands you run automatically run with sudo.
$ sudo -s
$ npm -v
$ npm list -g
Warning: If you don't have the password for sudo, you can't run any of the commands using sudo above.
This should fix your issue, if denied read/write access is the problem.
There are most likely many more solutions^^, but they might be added later.
^ This is a very usual process, but it has to be added here so that I can be sure that this solution has been tried.
^^ These solutions may be found later and edited to this answer. Edited once.
use this command :
npm list -g
you should see your npm directory at first line

What is the 'npm' command and how can I use it?

What is npm?
Whenever I browse through some project they ask me to run npm command, something like this
npm install -g node-windows
I went through some blog posts to learn about npm and I installed Node.js. However, when I run the above code in Node.js, I get the following errors:
When I browsed further, I came to know that the windows user can run the command from the cmd prompt window, but when I do that I get some output like this:
Which just generate a text file nothing else.
My questions:
How can I get started with the AngularJS2?
How can I run an npm command?
Do I require a command prompt to run the npm command (in Windows), or I can just use Node.js?
When I use the command npm install in my command prompt, I get the following output:
How to get started with the angularJS2
Follow this link and set up the project by following instructions
How to run a npm command
npm stands for Node Package Manager, and therefore you need Node.js installed before you can run npm commands.
Follow this and install the latest version. And restart the command prompt.
Do I require a command prompt to run npm commands (in Windows), or can I just use Node.js?
Yes, you need to run npm commands from the command line (in Windows).
E.g., npm install
You get the warning because there is no package.json file present where you are running the command.
ENOENT stands for Error NO ENTrey
Navigate to the project folder using the following command and then run npm install
cd <projectpath>
The AngularJS 2 website has everything you need to be covered. Their quickstart guide alongside with the quickseed zip file helps a lot.
But, in case you missed some points:
yes, you will need npm/NodeJS. So, download the latest distribution and have a clean installation of it.
you can execute the npm command with its parameters from within the Windows cmd.
the quickseed ZIP file contains all the files you need to see a live and quick example running locally. Unzip it on your workplace and navigate to it using the windows cmd. When inside the root folder of the unzipped package, execute npm install and right after it npm start.
Take the learning path. Step by step, all your questions will be answered.
You need to use an admin prompt for global installation (-g).

Running node apps with CodeDeploy

I am using Codeship as my CI tool, I integrate it with AWS CodeDeploy service. The procedure is perfect until my appspec.yml file calls my script to run the node app. Even though I have npm, node, bower and grunt installed I get command not found errors.
I would try editing your start_server.sh and adding npm and node to the $PATH environment variable or put that path directly in the command itself.
So instead of
npm install
Try
/usr/local/bin/npm install
That might not be where your npm lives but if you need to find out just do which npm
Perform the below steps:
which node
sudo ln -s /home/ubuntu/.nvm/versions/node/v12.13.1/bin/node (output of above step) /usr/bin/node
which npm
sudo ln -s /home/ubuntu/.nvm/versions/node/v12.13.1/bin/npm (output of above step) /usr/bin/npm
and try to use it via /usr/bin/npm install
I hope this will help you!!
For people who still might run into the same problem.
Check your appspec.yml file and look at the destination, it should contain something like /home/ec2-user....
in this case we need to make sure code deploy agent runs with that user profile (ec2-user). Check this link for steps to to make code deploy to run with your user profile

sh.exe": http-server: command not found

After I ran following command
npm install
it was successfully executed
But when i tried to execute following command
http-server
It gave following error
sh.exe": http-server: command not found
Can somebody help me out to solve the above error
You have installed the http-server package locally, rather than globally.
Check the node_modules/.bin/ folder, find the executable and execute that.
If that works try $(npm bin)/http-server if you are running from git bash. If you use the windows command prompt try node_modules\.bin\http-server.cmd from the same folder where you ran npm install

npm installing executable in usr/local/share/npm/bin rather than usr/local/bin

For example I tried installing npm serve globally
$ npm install -g serve
but after seemingly successfully installing it, I was unable to run the serve executable. Seems like the command just could not be found. Turns out the exe serve file was located in:
usr/local/share/npm/bin
rather than in what I thought should be (where all the other executable files are):
usr/local/bin
Any idea why I can't seem to get this to work?
Similar to this answer, create/edit ~/.npmrc to include:
prefix = /usr/local/bin

Resources