3

I want to start a simple local webserver for local development on Windows 7. For this I installed node.js and then ran:

npm install -g local-web-server

Next I went to the folder D:\[path_to_webcontent] containing the index.html, started a cmd-prompt from that folder and ran:

node ws

and get the error:

module.js:338

throw err;

^ Error: Cannot find module 'D:[path_to_webcontent]\ws'

Why can't node find the globally installed webserver? The module "local-web-server" is located at C:\Users\<user>\AppData\Roaming\npm\node_modules.

Lloyd
  • 8,204
  • 2
  • 38
  • 53
sotix
  • 822
  • 1
  • 8
  • 23

2 Answers2

6

Instead of node ws you just type wsin the cmd-prompt.

From the documentation on npm (https://www.npmjs.com/package/local-web-server):

$ npm install -g local-web-server
$ ws

When you write node ws node is looking to run a module called ws. When you want to use a globally installed package you just need to use the package's name in the cmd-prompt.

tokeryberg
  • 191
  • 4
0

If you used referencing module like this and nodejs can't find module path, try:

C:\Users\{your user name}\AppData\Roaming\npm\node_modules

and set the full path in require path or copy ws module folder inside your project folder

var ws= require('ws')

also you can use ../ before module to go one folder up. (relative path)

(remember to mark as answered and vote up ;) if you got the answer)

Reza Akraminejad
  • 1,412
  • 3
  • 24
  • 38
  • I don't want to reference the module, I want to run it. Since it was installed globally it should be available/startable from anywhere on the system. – sotix Oct 07 '15 at 07:05