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
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
For me removing my node_modules folder and running npm i
solve the problem
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.
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
For me, the cause was that I accidentally hit STRG + C while installing all the modules, which broke something.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With