1

Recently I installed a new Module for my Node Server which caused NPM to completely break.

The weird thing is that there is no module listed as not-found, but rather the dir/path to the File I'm using Node for.

Example:

module.js:491
throw err;
^

Error: Cannot find module '/path/to/file.js'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:598:3

This only happens after I install a Module (or potentially update one), help would be greatly appreciated!

  • `'/path/to/file.js'` is typically an example URL. Are you loading the example rather than the core library? Can you give us some detail about the library and how you are including it? – Sam R Sep 07 '17 at 11:48
  • /path/to/file.js was replaced by me. The actual Path is correct, I am 100% fond of that. EDIT: Just checked to make sure –  Sep 07 '17 at 11:51
  • Sorry for 2 replies in one chain; I'm not adding a library here, im simply executing a JS file with node. It seems npm got rid of all dependencies or broke the package json as no module required by the file I am executing is found. –  Sep 07 '17 at 12:02
  • Are you using a globally installed package, or one local to your project? Have you tried running `npm install` from your project root directory? – Sam R Sep 07 '17 at 12:13
  • Does this answer your question? [internal/modules/cjs/loader.js:582 throw err](https://stackoverflow.com/questions/53545800/internal-modules-cjs-loader-js582-throw-err) – Henke Jul 05 '20 at 15:37

1 Answers1

0

It turns out that the package.json file got completely destroyed during the installation of a Module (God knows why). Thus exisiting node modules weren't found, reinstalling them using the --save parameter listem them as dependencies again and the problem was fixed.

  • can you tell me the exact command that I need to put please? I'm still a newbie and I don't want to screw things up – Malek Zalfana Sep 10 '17 at 19:09
  • I don't exactly know what command you want, what I was referencing to here is the `--save` parameter when installing packages/modules with npm (`npm install package name --save`). –  Sep 11 '17 at 15:22
  • thanks for the reply, is it weird that I'm facing this nodejs error in a rails app? – Malek Zalfana Sep 11 '17 at 15:29