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 https://github.com/typeiii/jquery-csv)
Here is the structure of my project:
lucapuggini@lucas-MBP js_utils % ls
index.js index.js~ node_modules package-lock.json package.json
lucapuggini@lucas-MBP js_utils % ls node_modules
jquery-csv
lucapuggini@lucas-MBP js_utils % cat index.js
var csv = require('./jquery.csv.js');
console.log("Start index.js")
lucapuggini@lucas-MBP 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": "https://registry.npmjs.org/jquery-csv/-/jquery-csv-1.0.11.tgz",
"integrity": "sha512-KDPc3wFLTFO68p/4IqsODZCjBp+y9axDa/pr36pDKrWk6yyHf8Nk1FqAGXvaUb6H7J1zJSYszABIFj0a40QXRA=="
}
}
}
lucapuggini@lucas-MBP js_utils % node index.js
node:internal/modules/cjs/loader:922
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/lucapuggini/ProgrammingProjects/padel/trunk/js_utils/index.js'
]
}
lucapuggini@lucas-MBP 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');
when I added this line and do "npm install jquery-csv", there's still error saying there's no declaration, can you please advise on what to do?