Ex08 Node can't find modules "internal/modules/cjs/loader.js:605"

My Node install can’t find the proper module for Ex08. This is the error I get when trying to get node to reveal the path. I thought I selected “Add to PATH” “Entire feature will be installed on local hard drive.” when installing.

    PS C:\Users\Stephanie Westnedge\ljsthw> node --version
    PS C:\Users\Stephanie Westnedge\ljsthw> node process.argv
        throw err;

    Error: Cannot find module 'C:\Users\Stephanie Westnedge\ljsthw\process.argv'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
        at Function.Module._load (internal/modules/cjs/loader.js:529:25)
        at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
        at executeUserCode (internal/bootstrap/node.js:342:17)
        at startExecution (internal/bootstrap/node.js:276:5)
        at startup (internal/bootstrap/node.js:227:5)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

What I did to try to fix:
I tried different fixes from other sites (npm install, reinstalling node into my local “ljsthw” directory) but that didn’t work.
I upgraded from Node 10.14.2 to 11.5 but that didn’t work.
I removed ALL Node instances (including installers) and did a clean install of Node 11.5, rebooted, and that didn’t work. I closely followed the instructions in Ex00. I made sure to select “Add to PATH”, and I also opted for “Entire feature will be installed on local hard drive.” I did not install Chocolatey.

My environment
My machine: Windows 10 Home, 64-bit
My Node version: 11.5.0 (Downloaded x64 version)
I’m using Power Shell (not sure how to get version)
Node is installed here: C:\Program Files\nodejs
My working JS files are here: C:\Users\Stephanie Westnedge\ljsthw

Help, I’m really stuck.

Did you installed the readline-sync module?

npm install readline-sync

You will find some more instructions on this in the beginning of exercise 7 of LJSTHW.

I had some weird problems with this module too. After some tinkering I found out that I had some old nodejs installation lying around on my computer. After removing every thing related to nodejs from my computer (I using Linux, so can’t say how to do it on Windows) it worked after a fresh install of nodejs and the readline-sync module.

Yes, I did the readline-sync install before posting here. I’m not sure where else to look for old persistent files.

Okay. Does the below code work for you?

$ node
> const readline = require('readline-sync')
> readline.question("? ")
? lkjasdf

Open node

$ node


> const readline = require('readline-sync')
> readline.question("? ")

Hi @stepwest, very good question post! You’re going to kick yourself though:

node process.argv

Why are you typing that? Typically you would make a .js file, like ex08.js, and then run it with:

node ex08.js

What you typed is basically looking for a file named process/argv.js and when node doesn’t find it you get that error.

Hi @zedshaw, I was having trouble with this exercise, and I still believe my first attempts didn’t work because of a bad Node installation.

I thought – with my very limited knowledge – that if I typed

node process.argv

I could get the location of my Node installation and troubleshoot why I was having trouble. But now that you’ve explained that Node always expects a script, I won’t ever forget it!

It seems my module errors are now fixed with the second complete clean install I did yesterday and I successfully completed Ex08.

For anyone else, my working environment info:
Node version: 11.5.0
Node location is still: C:\Program Files\nodejs\node.exe
Ex08 file location is still: C:\Users\Stephanie Westnedge\ljsthw\ex08.js

1 Like

Hi @DidierCH
I can get the code to run like you described.

It seems the second clean install worked.
Thanks for your help.

Awesome. Happy coding!

Hmmm, well try to watch how you’re working and see if you’re doing something that is trashing your node installation. A good culprit of this is working in a directory like C:\Program Files\nodejs\ which you should stay out of at all costs.