I'm getting an error when trying to use any global module, exemple:
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (C:\BitNami\wappstack\...\test\app.js)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
I installed the express command:
npm install -g express
My app.js:
var express = require('express');
And run it using windows powershell or node.js command prompt windows:
node app.js
do not really know what's going wrong, I read something about environment variables in windows, can this be?
Resolved / Update
The problem was: Windows environment variables was not configured for npm folder. Search for your npm folder and add the path in the environment variables.
express
from any point by command line. If you runnpm install
in your projects directory and haveexpress
in your dependencies, it will work.