You are globally installing the package but not making it available in your node_modules folder for your project..
you need to give
npm i --save-dev themodule // this installs a devDependency for development purpose
npm i --save themodule // this installs a dependency and is for production ready.
(please see.. npm i is equivalent for npm install)
--
in short.. devDependencies object in package.json will have all the development related packages and dependency object will have production ready packages..
So.. to summon this.. when you say require('themodule'), then node checks whether this dependency package is available in node_modules folder or not..
so in your case it is not and that is the reason for the error..
Now, add the dependency package details in the package.json or do an npm i --save themodule