node.jsnpmnpm-installnpm-inittestserver

Problem with npm install --global http-server


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.


Solution

  • 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