Many npm and JavaScript Usage documentation missing something obvious. Please clue me in

0

I am looking at many different packages that have these two sections at the top:

  • Installation: npm install packageName
  • Usage: some JavaScript here, such as var X = require("packageName");

where packageName is the name of the package, for example please see jsDuck

After completing the npm command, I do the following to run the JavaScript, but node returns an undefined error:

C:> node
> var X = require('packageName');
undefined

I am familiar with usage syntax that is typically for a command-line. This JavaScript Usage documentation is eluding me.

I tried putting the JavaScript in a file and doing:

node file.js

but that resulted in the same undefined error.

Is there a prerequisite or another kind of secret I am supposed to know about before following the Usage instructions?

user1057211

Posted 2019-07-01T22:15:00.220

Reputation: 1

No answers