Reputation: 1211
Im playing around with a simple trading bot using binance and cctx
when i run my script with node index.js
i get this long error:
internal/modules/cjs/loader.js:323
throw err;
^
Error: Cannot find module '/home/ether/Documents/nodesendeth/node_modules/cctx/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:315:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:703:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:967:27)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/ether/Documents/nodesendeth/index.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32) {
code: 'MODULE_NOT_FOUND',
path: '/home/ether/Documents/nodesendeth/node_modules/cctx/package.json',
requestPath: 'cctx'
}
so it basically cant find the cctx module
cctx was installed with npm i cctx
and i also ran npm install
afterwards just to make sure.
It also says verify that package.json file has a valid main entry, which it does:
{
"name": "nodesendeth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"cctx": "^1.0.1",
"dotenv": "^8.2.0"
}
}
I pasted the code to my script here https://paste.ubuntu.com/p/p4n6MH3vbn/
Also my await functions arent working- even though i use them in an async function
So Im not a 100% sure what exactly the error is, there is a main entry in the package.json file and the cctx module has been installed
Upvotes: 98
Views: 255406
Reputation:
I have also faced the same Problem earlier. I solved the problem by deleting the node_modules folder and then
npm update
then
npm install
Upvotes: 8
Reputation: 61
Run npm update
, it will fix the issue
Or you can also delete node_modules
and the package-lock.json
file then npm install
will also solve the issue.
Upvotes: 6
Reputation: 553
For me, the cause was that I accidentally hit STRG + C while installing all the modules, which broke something.
Upvotes: 35
Reputation: 917
In my case, I was getting this error from my VS Code ESLint plugin output. However running the linter through the terminal was just fine. After exhausting other options, restarting VS Code did the trick and ESLint plugin runs.
Upvotes: 1
Reputation: 635
If you are working with firebase functions, and you are using TypeScript,
run the
npm run build
inside the Function directory
after that, a folder is generated in the current folder lib
then return back and fire!
$ firebase deploy
Upvotes: 3
Reputation: 101
If you are working with firebase functions, and you are using TypeScript, check the path to the generated index.js after npm run build
.
In my case it was lib/functions/src/main.js.
setting:
"main": "lib/functions/src/index.js",
on package.json
fixed the issue
Upvotes: 9
Reputation: 1670
https://www.npmjs.com/package/cctx <- Not a valid package. It's a typo for this package: https://www.npmjs.com/package/ccxt (CCXT instead of CCTX). Install that instead. The issue isn't with your code, it's that you installed the wrong package.
Upvotes: 3