I am using Node.js for a project. I installed WebdriverIO globally using
npm install -g webdriverio
In one of my files, I have:
file.js
var webdriverio = require('webdriverio');
When this file gets loaded, I get an error in the console that says:
Message:
Cannot find module 'webdriverio'
Details:
code: MODULE_NOT_FOUND
If I comment out the line var webdriverio = ...
, my code runs fine.
Considering I've installed webdriverio globally, I do not understand why I'm getting this problem.
Node.js require
looks into the local node_modules
folder.
Check this link to learn how to load modules from the global modules folder:
https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
If the NODE_PATH environment variable is set to a colon-delimited list of absolute paths, then node will search those paths for modules if they are not found elsewhere. (Note: On Windows, NODE_PATH is delimited by semicolons instead of colons.)
When you install globally, you should then go to the root of your app and call:
npm link webdriverio
P.S. no need to call npm install, since you will end up having two separate installations of this module, one in global and another in your local node_modules folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With