Can't install discord.js / can't find module discord.js

2020-03-26 javascript node.js npm discord.js

For the discord.js i install it 1st with npm: npm install discord.js and it seems to work.

idk why i got this error when i run the index.js file for the first time even i found that piece of code from the internet. (Apparently I am learning discord.js) It said that the module is not found. So, I try to install it again:

PS G:\My Drive\coding\node.js\bot> npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

+ [email protected]
added 15 packages from 17 contributors and audited 15 packages in 97.377s
found 0 vulnerabilities

And then i run the file index.js:

const Discord = require('discord.js');
const bot = new Discord.Client();
const botCommands = require('./commands');
const { prefix, token } = require('./cfg.json');


bot.on('ready', () => {`Logged in as ${bot.user.tag}!`);

And this is the result (console ofc)

PS G:\My Drive\coding\node.js\bot> node .
    throw err;

Error: Cannot find module './commands'
Require stack:
- G:\My Drive\coding\node.js\bot\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (G:\My Drive\coding\node.js\bot\index.js:3:21)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
  requireStack: [ 'G:\\My Drive\\coding\\node.js\\bot\\index.js' ]

Side note: before i even run index.js, I've run npm init -y to create a package.

PS G:\My Drive\coding\node.js\bot> npm init -y
Wrote to G:\My Drive\coding\node.js\bot\package.json:

  "name": "bot",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "keywords": [],
  "author": "",
  "license": "ISC"

P.S.: English is not my first language


If you cannot find the /commands folder - are you sure it is there? - make sure it is in the folder 'G:\My Drive\coding\node.js\bot\' Let me known if you have success