Discovering why npm cannot locate the installed package

Currently, I am utilizing Debian Stable Linux, which is updated and functioning flawlessly.

After globally installing the compute-pcorr package using the following npm command:

$ sudo npm install compute-pcorr -g

The package can be viewed with the command below:

$  npm list -g --depth=0 
/usr/local/lib
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="593a3634292c2d3c74293a362b2b196877697769">[email protected]</a>
└── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b7dadb9ac4c3d6c3f78699849984">[email protected]</a>

I am now endeavoring to test a sample code from its official page:

var pcorr = require( '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c6a5a9abb6b3b2a3ebb6a5a9b4b486f7e8f6e8f6">[email protected]</a>' ); 

var x = [ 1, 2, 3, 4, 5 ]; 
var y = [ 5, 4, 3, 2, 1 ];

var mat = pcorr( x, y );
Console.log("Correlation Matrix: "+ mat)

Nevertheless, upon running the above code snippet, an error ensues:

$ node compute_pcorr_usage.js 

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f1c10120f0a0b1a52">[email protected]</a>'

Furthermore, the following line of code does not yield the desired result:

var pcorr = require( 'compute-pcorr' ); 

Even after attempting to reinstall the package using this command, the error persists:

sudo npm install compute-pcorr -g --save

The issue lies within the code structure itself. How can this dilemma be addressed?

Answer №1

This problem occurs if the library is not installed on your local machine.
To fix this, try installing it in your directory by running the command npm install compute-pcorr
There's no requirement to install it globally using the -g flag.

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

Display the array elements in a comma-separated format using querySelector

Currently, I am utilizing querySelector from https://www.npmjs.com/package/qs with the objective of transforming an array into a comma-separated string. The process involves beginning with a URL search string and parsing it using the `qs` library. Subsequ ...

Automated playback of integrated Twitter video

Is there a way to make embedded Twitter videos autoplay? The code generates an iframe which is preventing me from using some JavaScript click tricks. Is there a workaround to enable autoplay? Plunker <script>window.twttr = (function(d, s, id) { v ...

How can one selectively apply a class to the initial DIV within a collection of dynamically generated DIV elements without relying on jQuery?

I am currently working on implementing a slideshow within a modal using AngularJS and Bootstrap. My challenge lies in dynamically creating DIVs, but specifically adding the active class to only the first DIV. Is there a way to achieve this without relying ...

.Certain IDs on a website may not respond to clicks due to various reasons

I have created a JavaScript file to automatically click a button on a website using a Chrome extension. When testing the code using Chrome Script snippet, I noticed that it worked for some IDs but not for others. Can someone please help me with this issue? ...

Guidance on executing a JavaScript function from PHP or HTML

Although this may appear simple to some, I am relatively new to this and have been searching everywhere. I currently have a javascript function. mkfile : function(fm) { I am attempting to run this from an on-click event. Any suggestions? I apologize fo ...

The controller is unable to provide the output in JSON format within the AJAX response

My task requires me to continuously call and fetch data from a REST API every second. To achieve this, I am calling the method with a time interval of 1 second as shown below: var myVar = setInterval(function(){ getData1() }, 1000); Below is the JavaScri ...

What is the process for accessing someone's birthday information using the Facebook API?

Working on integrating Facebook login and successfully retrieving user details such as first_name, email, etc. However, encountering an issue with fetching the birthday information. When attempting to call for birthday using the code snippet below, no data ...

What is the process for creating a local repository for Node.js npm?

When it comes to the building process in node js, there are a few goals that need to be called: Begin by calling npm install, which creates a folder called node_modules and places all dependencies from package.json into it. [for UI development] Execute a ...

Calculating Time Difference in JavaScript Without Utilizing moment.js Library

I have two timestamps that I need to calculate the difference for. var startTimestamp = 1488021704531; var endTimestamp = 1488022516572; I am looking to find the time difference between these two timestamps in hours and minutes using JavaScript, without ...

Securing JWT signatures for both server-side and client-side environments

I am looking to authenticate Salesforce's OAuth 2.0 JWT Bearer Flow using both node.js and a Browser. I have generated a public key and a private key on Windows by running the following command. openssl req -x509 -sha256 -nodes -days 36500 -newkey r ...

Tutorial on integrating jquery ui's '.droppable' feature with the jQuery '.on' method

I have a main div with three inner divs labeled 1, 2, and 3 as shown below: <div id="main"> <div style="height:30px; background-color:yellow;" class="bnr">Banner</div> <div style="height:30px; background-color:yellow;" class=" ...

"Deleting a database with a MongoDB / MongoLab Remove request successfully on a local environment, but accidentally removing

I am using nodejs, expressjs, and mongodb for this project. When the site is live, it utilizes mongolab. A POST request is sent from the front end to the server, where a single matching record in the database is deleted. The server-side code (written in Ex ...

What is preventing d3.json from including cookies in the request?

I'm delving into the world of ajax requests with d3.js (v5) and I'm facing a little hiccup. Here's my code snippet: d3.json(uri).then(data =>console.log(data)); When I tried this in an app utilizing cookie authentication, I consistently ...

Does the functionality of Protractor rely on a specific version of AngularJS?

Recently, I began exploring the world of Protractor. One burning question on my mind is its limitations and whether it relies heavily on a specific version of AngularJS. ...

Capturing numerous data points with JavaScript

<span> <label class="label">Color</label> <span class="foo"><input name="Color" value="Blue" class="customs" maxlength="100" type="text"/></span> </span> </span> <span> <label cla ...

Matching current URL and links by checking the div class

How can I verify if the current URL matches a link on my page, but also check if that link has a specific div class? For example: jQuery(document).ready(function($){ // find anchor tag on page with matching current location URL jQuery("*").find("a[h ...

How to disable sorting on the top LI element using jQuery?

I currently have two separate UL elements that are being sorted using the jQuery Sortable plugin. Each UL contains between one and ten LI elements arranged in a list format. $(".sortable").sortable({ connectWith: ".sortable", cancel: '.no-dra ...

Matching words with their meanings - exploring storage possibilities

I want to create a system to store vocabulary words and their translations in an organized manner... One idea I had was to use an associative array where each object represents a word and its translation. var vocab = []; vocab.push({"chinese" : "Nǐ", "e ...

Joining arguments beyond argv[2] in a Node.js application

Recently, I received a suggestion from Mykola Borysyuk to use node-optimist. However, the author mentioned that it's deprecated and recommended using Minimist. Even after going through the information, I have a basic understanding. Can someone provid ...

Ways to enhance the values in an array of objects sharing the same name and identical date

In my array of objects, I am seeking to calculate the total based on both the date and name. If the date and name match, I will combine the totals in the object. For example, consider the following list of objects: [{name: A, total: 3, date: 01-01-20},{nam ...