I am new to node.js and realized I can type node
into the terminal and load up a console (although I'm not sure if console is the right term here). I am wondering if when I start up this console, it loads into memory all of the dependencies I have defined in package.json
? Also - how is it different than, for instance, starting the node.js environment with yarn start
or npm start
? Is the entry point different when I just type in node
into the terminal?
Asked
Active
Viewed 1,103 times
2

rafiki_rafi
- 1,177
- 2
- 11
- 27
-
when you run npm start it will run script that is written in package.json. Sometimes that script can be same as calling file with node, but sometimes if will have additional arguments or so. – Mladen Skrbic Sep 11 '19 at 13:52
-
as for your question, dependencies are not imported from package.json, package.json is just for tracking dependencies that are stored in node modules and then you import it in file from node moduls folder. So yes your code will work if you run node filename.js – Mladen Skrbic Sep 11 '19 at 13:55
1 Answers
2
What you're loading when you just type node
is the node REPL, which stands for Read, Evaluate, Print, Loop. Think of this like an interactive node terminal; "console" is also a good term for it, imo.
It does not automatically load a project's package.json into the REPL when you launch it. You would have to use the .load command to do that. This answer on a similar question goes into a bit more detail.

rotarydial
- 2,181
- 2
- 23
- 27