RRP
RRP

Reputation: 2853

Have to run sudo npm install -g everytime

I am getting started on a command line application with node, i have noticed that every time i make a change to my index.js file i have to run "sudo npm install -g" to relfect the change. For example

index.js

#!/usr/bin/env node
console.log("Hello");

under my package.json

"bin": {
    "movie": "index.js"
  },

If i run "movie" from the terminal it prints out "Hello".

Now if i were to change the print statement under index.js to say console.log("World") and i run "movie" from the terminal it prints outs "Hello" rather than "World". But if i do "sudo npm install -g" and then run the "movie" command, it picks up "World".

I am not sure why this is happening?

Upvotes: 2

Views: 138

Answers (1)

Raulucco
Raulucco

Reputation: 3426

Use npm link instead of npm install. This will create a symlink on a directory that you can use for testing as if it was intalled locally on that directory.

Upvotes: 4

Related Questions