Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js local-web-server: can't find module ws (installed globally)

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.

like image 342
sotix Avatar asked Jan 17 '26 03:01

sotix


1 Answers

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.

like image 135
tokeryberg Avatar answered Jan 19 '26 18:01

tokeryberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!