Having trouble with N (Node Version Manager) post-installation - receiving error message "bash: n: command not found"

I am looking to handle node.js versions utilizing the n - node version manager.

To install n, I followed the instructions on Github at https://github.com/tj/n and executed the following command in my terminal:

sudo npm install -g n

Upon entering my password, the terminal output was:

/usr/local/lib/node_modules/node/bin/n -> /usr/local/lib/node_modules/node/lib/node_modules/n/bin/n
+ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="147a54223a243a25">[email protected]</a>

However, even after installing n, my terminal does not recognize the necessary commands and instead shows:

bash: n: command not found

The current version of node installed on my system is v12.3.0, while npm is version 6.9.0.

Any assistance would be greatly appreciated.

Thank you

Answer №1

The npm global packages commands are located based on the installation path present in your PATH environmental variable. It seems like there might be an issue with the prefix configuration, which could be related to how node and npm were set up.

In a standard setup, the bin directory within the npm prefix is added to the PATH, allowing the installed commands to be easily accessed.

$ npm prefix --global
/usr/local
$ sudo npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1bf91e7ffe1ffe0">[email protected]</a>
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$ command -v n
/usr/local/bin/n
$ n --version
6.0.1

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to combine a QR code and an existing image using Java script?

Looking for help in embedding a created QR code into an existing image. I am proficient in nodeJS, JavaScript, and jQuery. Any assistance would be greatly appreciated. ...

Is it possible to use npm to create an AngularJS project?

Is it possible to create an AngularJS project structure using npm or any other commands? Just like we use the following command to create a new angular project: ng new application_name Similarly, for creating a new react app we use: npx create-react-app ...

Guide for using express.js

Similar to how you can use to view the source code of all classes in Java, is there a resource available to view the source code of the express module? ...

Adding Packages to AngularJS: A Step-by-Step Guide

Recently, I decided to dive into learning AngularJS and NPM on my own. Using the book Professional AngularJS by Diego Netto and Valeri Karpov as my guide, I successfully installed the application with Yeoman and ran it using Grunt. However, I've hit ...

express session could not be authenticated by passportjs

Currently, I am integrating passportjs for authenticating my express app. Even though I have followed a tutorial closely, I keep encountering issues with session authentication. In my primary workflow, I authenticate users using the local strategy. passp ...

Error Message: "Unable to locate module for Angular 5 UI Components packaging"

In the process of developing UI Components to be used in various web projects throughout the company, we are aiming to publish these components as an npm package on our local repository. It is crucial for us to include the sources for debugging purposes. F ...

The fatal error encountered was completely unexpected: an Uncaught UnexpectedValueException was thrown due to the server returning an unprecedented value. The anticipated response was "HTTP/1.1 101", but instead, an

I am completely new to using socketIO and elephantIO. Currently, I'm attempting to emit data from a PHP file called "emit_test.php" to a node server. Here's the code snippet I've been working with: ini_set("display_errors",5); include ("v ...

Troubleshoot variable using EJS

Is there a way to set a global variable in EJS that can show/hide specific elements across all views without the need to redefine it each time? I am using node.js/express/ejs for my project stack and would like to know the best approach to achieve this. B ...

Running a Node Fetch POST call with a GraphQL query

I'm currently facing an issue while attempting to execute a POST request using a GraphQL query. The error message Must provide query string keeps appearing, even though the same request is functioning correctly in PostMan. This is how I have configur ...

filtering the properties of mongoose documents

I have created a schema as shown below: var UserSchema = new Schema({ firstName: { type: String, required: true }, lastName: { type: String, required: true }, email: { type: String, required: true }, location: { type: String, required: true }, p ...

Issue installing npm. What exactly is 'make'?

As a newcomer, you often have silly questions. I made sure to search Google and Stack Overflow before coming here. While there is a similar question posted, there doesn't seem to be a clear answer: npm failed to install time with make not found error ...

Building nested schemas in Mongoose for handling multiple arrays of objects

I'm currently in the process of developing a REST API using node, express, and MongoDB for a web application that has three main sections on the frontend: Quotes Stories News When a user clicks on Quotes, they should only see quotes; the same goes ...

The issue of receiving a "collection is not a function" TypeError often arises when trying to link MongoDB and NodeJS together

I am a newcomer to MongoDB and currently working on establishing a connection between my ExpressJS server and a MongoDB database. Below is the code I have written for this purpose: const PRIMARY_SERVER = "mongodb://localhost:27017/"; const { M ...

Running `ng start angularProject` or `npm install` will generate additional files in the project's

I'm encountering a major issue where every time I create a new project using 'ng start' or run 'npm install', extra files are being generated in the root folder like this. https://i.stack.imgur.com/BUphZ.png Here is my package.js ...

What prevents my kittens from vocalizing once I bring them back from the database?

Trying to implement the code from http://mongoosejs.com/docs/index.html, but I seem to be missing something fundamental. Why does the schema not get applied to the objects I retrieve? The Issue const mongoose = require('mongoose'); mongoose.con ...

Is it possible for me to customize the jQuery library?

Looking to make changes to the jQuery.post function in order to tackle the CORS issue. Having to write extensive code like below when using jQuery.ajax can be tedious: $.ajax({ url:'', data:null, type:'post', xhrFields ...

The system encountered an issue with the CSS code, indicating "Invalid CSS after "...inear-gradient(": expected selector, was "{"

While attempting to compile my sass code, I encountered the following error message regarding a syntax issue: /* { "status": 1, "file": "C:/Users/faido/Desktop/Productivity/sass css/project/sass/main.sass", "line": 36, "column": 9, "mes ...

Error: 'require' function is not recognized in the latest JavaScript file

I am interested in using anime.js. To install this library, I need to follow these steps: $ npm install animejs --save const anime = require('animejs'); The code should be written in a js file named "anime.js" Here is the code for "anime.js": ...

The mongoose library fails to identify the collection based on its name

Here's my modified code: var mongoose = require('mongoose'); var db = mongoose.createConnection('localhost', 'bttf'); db.once('open', function() { var schema = new mongoose.Schema({ name: String, ...

Guide on Utilizing Forever Alongside Express for Continuous Operation of a NodeJS Server

Currently, I have an Express NodeJS server that I personally initiate via the terminal with npm start in the root directory of my project. To ensure consistent uptime, I opted to install the Forever package globally. However, when I try to run Forever on m ...