Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'node-static'

I am trying to run samples regarding webrtc. For that I went to

https://bitbucket.org/webrtc/codelab/src/50a47bb092483fd7ca27998a365dff434919bf89?at=master

At step 5 I needed to run server.js. For that I opened my Windows Command prompt and entered:

C:\Program Files\nodejs>node D:\GITProjects\codelab\complete\step5\server.js

But I got this error:

module.js:338
    throw err;
          ^ Error: Cannot find module 'node-static'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (D:\GITProjects\codelab\complete\step5\server.js:1:76)

    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

I have already installed node-static module and it is present at

"C:\Program Files\nodejs\node_modules\node-static"

enter image description here

Still I am getting the error "Cannot find module 'node-static'".

Environmental "PATH" variable is set to "C:\Users\user\AppData\Roaming\npm"

I can see the node-static folder is present at "C:\Users\user\AppData\Roaming\npm\node_modules\node-static" path too.

Edit:

Based on the comments I tried this on Windows Command Prompt to install node-static:

C:\Program Files\nodejs>npm install node-static -g

I got this as the output:

C:\Users\user\AppData\Roaming\npm\static -> C:\Users\user\AppData\Roaming\np
m\node_modules\node-static\bin\cli.js
[email protected] C:\Users\user\AppData\Roaming\npm\node_modules\node-static
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected])

Can you help me location the cause of my issue?

like image 454
Raghav Avatar asked Oct 20 '22 07:10

Raghav


2 Answers

node_static is not an inbuilt nodejs module so there should be a folder node_modules in your doc root folder(step5) with this module in it or create a package.json and list it as a dependency then run npm install before node server.js

like image 139
danleyb2 Avatar answered Oct 22 '22 03:10

danleyb2


just run npm install on cd into the "complete" directory i.e codelab\complete

like image 29
saurabh jain Avatar answered Oct 22 '22 01:10

saurabh jain