node js MODULE_NOT_FOUND error in node_modules

I am new to javascript and I am having import issues.

I have installed the jquery.csv lib as npm i jquery.csv but then node is not able to import it. (this was the procedure described in

Here is the structure of my project:

[email protected] js_utils % ls
index.js                index.js~               node_modules            package-lock.json       package.json
[email protected] js_utils % ls node_modules 
[email protected] js_utils % cat index.js

var csv = require('./jquery.csv.js');

console.log("Start index.js")
[email protected] js_utils % cat package-lock.json 
  "name": "js_utils",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "jquery-csv": {
      "version": "1.0.11",
      "resolved": "",
      "integrity": "sha512-KDPc3wFLTFO68p/4IqsODZCjBp+y9axDa/pr36pDKrWk6yyHf8Nk1FqAGXvaUb6H7J1zJSYszABIFj0a40QXRA=="
[email protected] js_utils % node index.js
  throw err;

Error: Cannot find module './jquery.csv.js'
Require stack:
- /Users/lucapuggini/ProgrammingProjects/padel/trunk/js_utils/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/lucapuggini/ProgrammingProjects/padel/trunk/js_utils/index.js:2:11)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
  requireStack: [
[email protected] js_utils % 

Why am I getting this error?


It seems their documentation is incorrect. You need to require the npm module like this:

const csv = require('jquery-csv');