Giter VIP home page Giter VIP logo

Comments (12)

jonahoffline avatar jonahoffline commented on April 28, 2024 1

@arapehl If you installed it globally, you call it just by running http-server

There are two ways to run the bin from a local install
(Assuming you ran npm install http-server)

Calling it directly:
./node_modules/.bin/http-server

or using this script I made npm-run script.
First make it executable:
chmod +x npm-run

To run (You can pass any argument also):
./npm-run http-server

I suggest you copy the npm-run script into /usr/local/bin/ so you can use it from any folder where you have node modules that need run locally.

from http-server.

arapehl avatar arapehl commented on April 28, 2024

I'm also having this problem.

from http-server.

mmalecki avatar mmalecki commented on April 28, 2024

Node uses modules installed locally. There's no way to include a module installed globally.

from http-server.

vcao avatar vcao commented on April 28, 2024

The install instructions for http-server are for a global.

from http-server.

mmalecki avatar mmalecki commented on April 28, 2024

Yes - "This will install http-server globally so that it may be run from the command line.". You need to install locally to use it as a module.

from http-server.

arapehl avatar arapehl commented on April 28, 2024

But I get the error when I install globally and try using it on the command line. It keeps looking for the bin locally.

from http-server.

mmalecki avatar mmalecki commented on April 28, 2024

How are you running it?

from http-server.

arapehl avatar arapehl commented on April 28, 2024

I simply type node http-server and it says: Error: Cannot find module '/Users/ara/dev/projects/github-link/http-server' It's looking for it in the dir I'm in instead of looking in /usr/local/lib/node_modules/ where npm global installs it. From what I understand from the docs, it should just run from the dir I'm in.

from http-server.

arapehl avatar arapehl commented on April 28, 2024

OK, now I feel dumb. My mistake was that I was running node http-server rather than just http-server. Thanks for that and sorry for the trouble.

from http-server.

jonahoffline avatar jonahoffline commented on April 28, 2024

Don't sweat it dude!
No problem πŸ‘½

from http-server.

mamsdou avatar mamsdou commented on April 28, 2024

thx @jonahoffline

from http-server.

changshoumeng avatar changshoumeng commented on April 28, 2024

I had this problem,too.I solve it. This is my idea.

D:\fs\envs\nodejs2>npm install remix-ide -g
C:\Users\changshoumeng\AppData\Roaming\npm\remix-ide -> C:\Users\changshoumeng\AppData\Roaming\npm\node_modules\remix-ide\bin\remix-ide

D:\fs\envs\nodejs2>remix-ide
module.js:549
throw err;
^

Error: Cannot find module 'http-server'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\changshoumeng\AppData\Roaming\npm\node_modules\remix-ide\bin\remix-ide:2:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

D:\fs\envs\nodejs2>npm-run http-server
'npm-run' δΈζ˜―ε†…ιƒ¨ζˆ–ε€–ιƒ¨ε‘½δ»€οΌŒδΉŸδΈζ˜―ε―θΏθ‘Œηš„η¨‹εΊ
ζˆ–ζ‰Ήε€„η†ζ–‡δ»Άγ€‚

D:\fs\envs\nodejs2>npm install http-server -g
C:\Users\changshoumeng\AppData\Roaming\npm\http-server -> C:\Users\changshoumeng\AppData\Roaming\npm\node_modules\http-server\bin\http-server
C:\Users\changshoumeng\AppData\Roaming\npm\hs -> C:\Users\changshoumeng\AppData\Roaming\npm\node_modules\http-server\bin\http-server

D:\fs\envs\nodejs2>remix-ide
Starting Remix IDE at http://localhost:8080

from http-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.