简体   繁体   中英

node:internal/modules/cjs/loader:922 throw err; ^ Error: Cannot find module

Help me please, I was trying to create a currency system following the discord official guide ( https://discordjs.guide/sequelize/currency.html#create-models ) and copying and pasting all the code sections but, at the moment of writing node., he gives me this horrible error: can anyone please help me? I would be really glad. I've also tried all the recommended solution that have been posted on the site:

  • Delete the node_modules directory.

  • Delete the package-lock.json file

  • Run npm install

  • Run npm start

Nothing changed. Thank you

My path: C:\Users\HP\Desktop\Economy

Complete error lyst:

node:internal/modules/cjs/loader:922 throw err; ^

Error: Cannot find module 'C:\Users\HP\Desktop\Economy' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15) at Function.Module._load (node:internal/modules/cjs/loader:763:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }

You are using a module, which you have not installed. You get modules with the require() function. So check your code for those functions and look what is inside () of require() . Then go to your terminal and type npm i "ModuleName"@latest .

For example you have a line const Discord = require('discord.js'); . Type npm i discord.js@latest in your terminal. Now the latest version of the module was added to node_modules and you should be able to run your code without any problems.

I also got the similar error few days back but then i resolve it by following steps... 1.If you are running this code from terminal then you might get error but if you install code runner from vs code extensions and then click on that play button(which will appear on the top-right side ) then the code runs properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM