Closed ghost closed 7 years ago
Installing node globally (the -g
flag) gives you access to it via the command line, but not via require
.
To get access to a package via require
it must be installed in the current directory's node_modules
, or the node_modules
of an ancestor's directory.
To install a package locally, you would remove the -g
flag. If you are starting a new node project, then you would want to have a package.json
file that can be created by npm init
For more information see https://nodejs.org/api/modules.html
This is a really weird error I keep getting. Been digging around google trying to find a solution, but can't find one. I did a global install for cson and when I run node and attempt to import the cson module with require(), I get an error.
I did a fresh install of the latest stable versions for node and npm and updated npm afterwards. I then ran the following commands.
When I went to test out if I could import the cson module, I got this output.
Any help with this would be greatly appreciated. Keep in mind, I am still new to using node.