Error: Cannot find module dotenv

Asked

Viewed 1,993 times

1

I did the installation of modele as Dev:

C:\Users\mrgen\OneDrive> npm i dotenv --save-dev
    npm WARN [email protected] No description
    npm WARN [email protected] No repository field.        

    audited 299 packages in 3.987s
    found 0 vulnerabilities

The configuration file has been updated correctly: inserir a descrição da imagem aqui

The file was imported with require(): inserir a descrição da imagem aqui

When I run the file, see what happens:

C:\Users\mrgen\OneDrive> node src/index

module.js:549
    throw err;
    ^

Error: Cannot find module 'dotenv'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\mrgen\OneDrive\src\index.js:14:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

This does not happen if I install dotenv in the project. Am I calling the module wrong? Why can’t Node locate the module?

  • 1

    Are you sure that Environment is set to dev?

  • Where do I see it?

  • Hello, you installed the module in the directory C:\Users\mrgen\OneDrive> right, but in the stack he points out that you are in this directory C:\Users\mrgen\OneDrive\cursos\javascript\pesquisas\cadastro\src\index.js, it is good to check the directories in question

  • um... I decreased the size of the directory to get cleaner (formatted), but it’s all in C: Users mrgen Onedrive courses javascript research register. But I just edited out the question.

  • Try to install project dependencies, that must be it. Can be with the Yarn command

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.