As the title says, node cannot find main.js. I am doing this through replit and my .replit file is run = "npm test"
. My package.json file is
{
"name": "Adventure",
"version": "1.0.0",
"description": "This is The Adventure Bot By BrainDead_Dev",
"main": "main.js",
"dependencies": {
"@replit/database": "^2.0.1",
"discord-buttons": "^4.0.0-deprecated",
"discord.js": "^13.6.0",
"moment": "^2.29.1",
"winston": "^3.6.0"
},
"devDependencies": {},
"scripts": {
"test": "main.js"
},
"repository": {
"type": "git",
"url": "git https://github.com/BrainDeadDev/Adventure.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/BrainDeadDev/Adventure/issues"
},
"homepage": "https://github.com/BrainDeadDev/Adventure#readme"
}
This is for a discord bot, and it has been working perfectly fine up until the point where I wanted to update discord.js and had to reinstall npm. Any help would be appreciated as I am quite lost.
CodePudding user response:
When you updated the discord.js package, it now requires a more current version of node js (v16.6).
To update to the version of node using npm simply run:
npm install -g n
If you are using nvm you can do:
nvm install 16.6
then tell nvm to use the new version:
nvm use 16.6
Then you can check the version you are using by running:
node --version
Edit for Repl.it:
following this blog, you should be able to do it by running this:
npm i --save-dev node@16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH
You can also try following this question on repl.it forums