-1

I'm trying to install a test server in vscode using npm install --global http-server, after I cd to my current folder where my code is, when I run the command I'm supposed to get a node_modules folder and then I should run npm init to get package.json, however that's not the case and instead I get this message after running install server:

changed 34 packages, and audited 35 packages in 12s

7 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

And when I try to run npm init, it asks me for the name of the file I want to create and some other parameters such as author, license, etc. I tried looking in the forum but I couldn't solve it yet.

Arialita
  • 15
  • 1
  • 5
  • “*when I run the command I'm supposed to get a node_modules folder*” Not quite - can you share how you reached the conclusion that this should happen when you install a package to the global path with `--global`? – esqew Jan 09 '22 at 15:50
  • I'm taking a web development course provided by the government of my country(Argentina) and they gave us a PDF that was initially talking about typescript and nodejs and at some point in the pdf, it said that I had to run that command and I should see the node_modules folder in my proyect's directory. I assumed I had to cd there, I tried without installing globally and still got the same message. But my problem was solved anyway, now Ill look how to install it globally! – Arialita Jan 09 '22 at 16:19

1 Answers1

1

You're using the --global parameter, which tells npm to install the module into the global path, not in the local node_modules/.

If you need to install http-server as part of a project, first run npm init and then

npm install --save-dev http-server

or

npm install --save http-server
VaiTon
  • 371
  • 2
  • 11
  • 1
    Thank you! it really helped me, I first ran npm init and created a file named package, then I ran npm install --save http-server and I got the node_modules folder! Then I opened package.js and edited the scripts part like this: "start": "http-server -p 8456" and it worked. – Arialita Jan 09 '22 at 16:21