'My node.js gives me error and I dont understand what's the problem
This is the error please help me. I tried to npm install @discord-api-types/v9 but nothing changed. I am trying to create a discord bot but when I type node index.js to terminal it keeps giving me error.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '@discord-api-types/v9'
Require stack:
- C:\Users\MONSTER\Desktop\Rayman Music\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\MONSTER\Desktop\Rayman Music\index.js:4:20)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\MONSTER\\Desktop\\Rayman Music\\index.js' ]
}```
Solution 1:[1]
The MODULE_NOT_FOUND error means it can't find either a package or a file, in this case a package.
Ensure you have the package discord-api-types by doing
npm install discord-api-types
Solution 2:[2]
This might be due to npm version.
In old versions, you need to write a flag in command to add the module to dependencies.
npm install <module> --save
Check version, but first check whether that module has been added to dependencies after executing npm install command without flag in package.json file
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ThatsLiamS |
| Solution 2 |
