Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
how do i solve this error while running javascript in my node.js?

i want to run my script "script.js" on node.js use command "node script.js" but i got this error

  node:internal/modules/cjs/loader:936
  throw err;
  ^
    Error: Cannot find module 'C:\Users\User\script.js'
    [90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)[39m
    [90m    at Function.Module._load (node:internal/modules/cjs/loader:778:27)[39m
    [90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)[39m
    [90m    at node:internal/main/run_main_module:17:47[39m {
      code: [32m'MODULE_NOT_FOUND'[39m,
      requireStack: []
    }

can anyone help ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Please ensure that you are running the node command in the same folder that the script.js file exist. If you are opening command prompt from a different location and try running node script.js, an error will be thrown as

internal/modules/cjs/loader.js:883 throw err; ^

Error: Cannot find module 'C:\yourpath\script.js' [90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)[39m [90m at Function.Module._load (internal/modules/cjs/loader.js:725:27)[39m [90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)[39m [90m at internal/main/run_main_module.js:17:47[39m { code: [32m'MODULE_NOT_FOUND'[39m, requireStack: [] }

This indicates that the file doesnot exist in the desired path.

As per your question, you are running the command from C:\Users\User, so your script.js file must be there at the location C:\Users\User\script.js. If your script.js is at some other location, say C:\Users\yourusername\somerandomfolderpath, then you have to open your command prompt at that folder or go to that location using command prompt using these commads.

C:
cd C:\Users\yourusername\somerandomfolderpath

The first command takes you to the required drive (expecting it to be C drive here). The second command takes to the required folder in that drive.

After this you can run your script using.

node script.js
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda