1

I set the prefix of npm to d:\npm and installed various modules globally, also I added d:\npm to the Path environment variable and created a NODE_PATH variable pointing to d:\npm\node_modules.

The installed Files are all in den expected directory and stuff like protractor --version works.

However when I require a globally installed module(with require('jasmine-trx-reporter')) I get an error that it cannot be found.
On a different machine where I have all the dependency's as dev-dependency installed the same project works with no problems so it has to be some linking issues.

Would appreciate any help.

  • Possible duplicate of [How do I import global modules in Node? I get "Error: Cannot find module "?](https://stackoverflow.com/questions/7970793/how-do-i-import-global-modules-in-node-i-get-error-cannot-find-module-module) – Skippy le Grand Gourou Apr 19 '19 at 09:51

1 Answers1

0

This will not work:

require(jasmine-trx-reporter)

You need to use:

require('jasmine-trx-reporter');

with quotes. Maybe it was just a typo in the question.

You shouldn't rely on modules being installed globally. It's best to add them to dependencies (or devDependencies) in package.json, use npm install to install them and be sure what you are requiring.

Relying on the packages being installed globally is asking for trouble.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • Thank you, it was indeed a typo, I will correct it. However I need it to install the modules globally because it gets deployed on an Team Foundation Server where the project files will be always purged on build and I dont want to install the modules every time. – Transzendental Mar 20 '17 at 17:07