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 ment 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.
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 ment 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.
Share Improve this question asked Sep 5, 2015 at 14:43 JQuery MobileJQuery Mobile 6,30124 gold badges88 silver badges138 bronze badges5 Answers
Reset to default 5When 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
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/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.)
You need it locally for your app, run npm install webdriverio
in the root directory of your app.
Node looks for modules in the innode_modules
folders only (starting with current folder and then looking in the folder above). In order to make it work, you have to install this package locally as well.
npm install webdriverio
You can use the full global path:
const wdio = require('/usr/local/lib/node_modules/webdriverio');