let ex18 = require(’./ex18’)
{ Error: Cannot find module ‘./ex18’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18) code: ‘MODULE_NOT_FOUND’ }
I have tried typing in the entire file path in node and different file names such as ‘ex18.js’, etc but get the same message.
Welllll, when you save the file you should try to be aware of where it gets saved so you can cd to it. If you have no idea where then enter this command:
find ~/ -name “ex18.js” -print
That might take a while, since it’s searching your whole home directory, but when it’s done it should print out where ex18.js lives. Then cd to that directory. So if it says:
Documents/ex18.js
Then you do:
cd Documents
Also, you should have watched the Ex0 video for MacOSX. I go through how to correctly setup your environment and part of that is creating an ljsthw directory and saving the file in the correct place. If you’re on 18 and still have no idea where things are being saved then I’d say you need to start over as where you save files is a critical part of programming.