What steps do I need to take to develop a CLI application similar to ng, that can be installed globally on the system

Upon installing

npm i ng -g

How does the system determine the installation path?

I am interested in creating an application that can be installed and executed similarly.

Answer №1

When you execute npm install --global, it is typically done for packages that have a command line interface (CLI) component. To discover the location of these packages, the UNIX which command can be quite useful.

For instance, when NodeJs is installed, npm is usually set up as a global package. Thus, you should be able to locate it easily by running:

$ which npm 
/home/myuser/.nvm/versions/node/v12.16.1/bin/npm

The specific path may vary based on different factors such as your operating system, installation method for node, set environment variables, symlinks, etc. Perform an ls command on this path excluding the bin/npm section at the end.

$ ls /home/myuser/.nvm/versions/node/v12.16.1/
bin  CHANGELOG.md  include  lib  LICENSE  README.md  share

This directory represents the "global" node setup.

To address your initial query regarding the location of ng, add node_modules/${PACKAGE_NAME} to the global node directory and run ls. In my situation, this would appear as follows:

$ ls /home/myuser/.nvm/versions/node/v12.16.1/lib/node_modules/ng
ls: cannot access '/home/myuser/.nvm/versions/node/v12.16.1/lib/node_modules/ng': No such file or directory

Since I do not have ng globally installed, the ls operation above fails. However, in your specific scenario, you should observe the contents of the ng package installation.

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

Ensuring consistency between TypeScript .d.ts and .js files

When working with these definitions: https://github.com/borisyankov/DefinitelyTyped If I am using angularJS 1.3.14, how can I be certain that there is a correct definition for that specific version of Angular? How can I ensure that the DefinitelyTyped *. ...

Is it possible to utilize viewport height as a trigger for classes in Gatsby?

Unique Case Working on a Gatsby site with Tailwind CSS has brought to light an interesting challenge regarding different types of content. While the blog pages fill the entire viewport and offer scrolling options for overflowing content, other pages with ...

I am in need of assistance in developing an image slider using react.js. Can you help

let projects = [{id: 1, img: "https://scontent-lax3-2.xx.fbcdn.net/v/t1.0-9/117405206_1535037326696077_4967665142447981078_o.png?_nc_cat=111&ccb=2&_nc_sid=730e14&_nc_ohc=XlNXGJF47E0AX8lB1fk&_nc_ht=scontent-lax3-2.xx&a ...

What is the best way to transfer variables defined in PHP to JavaScript?

Can the variables previously defined in JavaScript be used in the line that starts with $sql =? var southWestLat = map.getBounds().getSouthWest().lat(); var southWestLng = map.getBounds().getSouthWest().lng(); var northEastLat = map.getBounds().getNort ...

Encountering an issue with authentication credentials while using NPM dependencies on Google Cloud AppEngine

After creating a Node.js project called "AA" in Google Cloud (GC) Repository, I proceeded to create another project labeled "BB" and included "AA" as a dependency: "dependencies": { "@slack/client": "^4.9.0", "axios": "^0.18.0", "big-integer": "^1.6 ...

Organize intricate JavaScript Arrays

Similar Question: How to sort an array of javascript objects? I'm in the process of transitioning some of my older ActionScript 2.0 code to JavaScript. While most things are running smoothly, I've hit a roadblock when trying to numerically s ...

Can qTip 2.0 be configured to use a different default attribute instead of 'title'?

Is there a way to set qTip to use an attribute other than 'title' as the default? I need to use another attribute because when I disable qtip and add elements dynamically with "title", the title still shows when I hover over the element, which i ...

Is there a method in TypeScript to make an enum more dynamic by parameterizing it?

I've defined this enum in our codebase. enum EventDesc { EVENT1 = 'event 1', EVENT2 = 'event 2', EVENT3 = 'event 3' } The backend has EVENT1, EVENT2, EVENT3 as event types. On the UI, we display event 1, event 2, a ...

Getting the true height without needing jQuery

let element = document.getElementById('test'); console.log(element.scrollHeight); <div style="height: 30px;" id="test"> <p>ffffffffff</p> <p>gggggggggg</p> ...

Custom-designed background featuring unique styles

I have implemented the following code to create a continuous running banner: <style> #myimage { position: fixed; left: 0%; width: 100%; bottom: 0%; background:url("http://static.giga.de/wp-content/uploads/2014/08/tastatur-bild ...

Creating dynamic elements in JavaScript utilizing Bootstrap cards

Looking for help in integrating Bootstrap cards while dynamically generating elements using JavaScript? I am working on a project where I need to generate a list of restaurant recommendations based on user preferences entered through a form, utilizing the ...

Failed to load Gulpfile.js in the Task Runner Explorer of Visual Studio 2019 version 16.6.2

Displayed below is the result in the output error window. Failed to execute "D:\TortSVN\Oil Diversity\Main Web App\LatsetOildiversity\Gulpfile.js"... cmd.exe /c gulp --tasks-simple fs.js:27 const { Math, Object } = primordials; ...

Animate the Bootstrap carousel from top to bottom instead of the traditional left to right movement

Is there an option available in the bootstrap carousel to animate it from top to bottom and bottom to top, rather than from right to left and left to right? jsFiddle link <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval=" ...

ReactJS state not being updated due to a nested Axios call

Attempting to fetch data from nested axios calls, successfully retrieving responses from both calls. Struggling to update the prize_pool value within the second axios call. Any assistance would be greatly appreciated. getAllLeague() { axios.get(BA ...

Jquery's ajax function is failing to execute the server side function

I have a specific structure for my solution: My goal is to execute the recommendationProcess function from CTL_RateRecommendationDetails.ascx.cs in CTL_RateRecommendationDetails.ascx Therefore, I wrote the following code: $.ajax({ type: "POST", ...

Manipulating data in node.js as it arrives in separate chunks

Hey there, I am trying to make some changes to the data received from the server. All incoming data via the POST method is processed in chunks. <button id='helloButton'>Send hello!</button> <button id='whatsUpButton'>S ...

Concealing or revealing an image with jQuery when hovering

I currently have 3 <a> tags within my html, each containing 2 images. Specifically, the greyscale images are the ones that are visible while the colored ones are set to display:none. I am aiming to achieve a functionality where upon hovering over th ...

Express fails to handle the POST request

Using ejs, express, nodeJS and mySQL has been great so far. However, I'm facing an error with this code: Cannot POST /search. I believe the index.ejs and app.js files are okay, but I suspect there's a problem with the searchRouter... app.js cons ...

AngularJS: accessing remote systems - a guide

I am looking to explain my objective clearly I need guidance on how to establish a remote desktop connection from my Angular.js application to a windows application running system. The server I am using is Google App Engine. My current ideas: The Windo ...

Login attempt with Clasp unsuccessful: 'Issue encountered while retrieving access token...'

I need help setting up Clasp on my Windows 10 PC for Google Apps Script. I am facing an issue when trying to log in via the command line (clasp login). It opens a browser tab where I log in to Google, and the webpage confirms successful authentication. How ...