0

First of all,I am running everything on Windows. What happens is: When I type in terminal: 'node app.js' to run my script, an error occurs , it says it won;'t find the openlayers module.HOWEVER:

That according to my knowledge it means that it will not find the openlayers module that I require in my app.js file like this:

var OpenLayers = require('openlayers').OpenLayers;

Although I have installed openlayers module both locally and globally still it will pop up the error.

Also, I have set the NODE_PATH in system variable to the folder that contains the archives of the modules!

Guys and girls, what could be wrong, I am running out of options? Could it be the module itself? All other modules are recognised according to plan. When I go

npm list -g 

all the modules are installed according to plan!

EDIT 1: I have set the NODE_PATH variable to %AppData%\npm\node_modules but still it won't work! The folder 'app.js' is in and I run the 'node app.js' command in has no m\'modules' file. This local file exists one folder back.

EDIT 2: Here's a screenshot of my error : http://prntscr.com/4zfiyn

drizo
  • 267
  • 6
  • 14
  • Perhaps relevant: http://stackoverflow.com/questions/9587665/nodejs-cannot-find-installed-module-on-windows – jfriend00 Oct 24 '14 at 21:28
  • @jfriend00 Thanks for answering! I tried it the answer given to the question and it doesn't seem to work.I wonder if that stuff happens in linux systems like ubuntu? This consumed my whole working day and still no fix! – drizo Oct 24 '14 at 23:11
  • For global modules, it seems like some sort of environment variable is missing that needs to point to where the global modules are. For locally installed modules, it depends upon the current working directory at the time you launch node so you may want to make sure you're launching node from the right place or that you set the current working directory before launching node. – jfriend00 Oct 24 '14 at 23:19
  • @jfriend00 ok the NODE_PATH variable is set to '%AppData%\npm\node_modules' which in my system points at the module file. Secondly, I am launching the 'node app.js' command from a folder that although I 've run the 'npm install 'x'' in it, it seems that the 'node_modules' file is not in it.It is one folder back. This has driven me crazy I think I am going to install another OS for my desktop to solve this. – drizo Oct 24 '14 at 23:31
  • @jfriend00 Since I can't upload a picture on my question,I upload it here. Please check the Screenshot of my error. http://prntscr.com/4zfiyn – drizo Oct 24 '14 at 23:34
  • Do you have the same issue if you just use `node app.js` instead of `nodemon app.js`? Also, please show the node_modules hierarchy below app.js? – jfriend00 Oct 24 '14 at 23:50
  • @jfriend00 If I use 'node app.js' the same happens. The hierarchy is Desktop/Projects/ProjectFolder/app.js and for the node modules is Desktop/Projects/node_modules. I tried to copy the node_modules folder in ProjectFolder but it failed for soem reason. However I have tried installing the npm install *module* in the app.js folder. – drizo Oct 25 '14 at 00:10
  • `node_modules` has to be below the current directory to be considered for local modules. Your `node_modules` directory isn't in the right place. – jfriend00 Oct 25 '14 at 00:13
  • @jfriend00 How would I do that? I tried to copy paste the folder but some error occur? Is there an obvious way to do it that I am missing? – drizo Oct 25 '14 at 07:36
  • Go to the current directory of your app.js file and then install the modules you need with npm and npm will put them in the right place for you. – jfriend00 Oct 25 '14 at 07:41
  • @jfriend00 thanks for your answers and all the time and energy you've put in my question. The thing is when I install the modules I install them in folder where app.js is but it gets installed one folder back? How is that possible? Is there any path taht defiens where the moduels are installed? – drizo Oct 25 '14 at 11:34
  • I couldn't find a solution, so I formatted my computer and installed Linux Mint instead of 'variable pathed' Windows OS. – drizo Oct 25 '14 at 20:13

0 Answers0