Note that there are some explanatory texts on larger screens.

plurals
  1. PONPM package.json dependencies and their executables in local vs global
    text
    copied!<p>I think <code>npm install|update</code> works when requiring dependencies in source files, but when I want to run an executable, like <code>nodemon</code>, it doesn't appear to work. Is it trying to look for the file globally? How can I make these commands look in <code>node_modules</code> first? </p> <hr> <p>I have a Cakefile that starts the dev server with <code>nodemon</code>. For example:</p> <pre><code># **`procExec(procName)`** # returns the path to executable in `node_` procExec = (procName) -&gt; console.log "./node_modules/" + procName + "/bin/" + procName "./node_modules/.bin/" + procName # **`cake startdev`** # Starts the server with `nodemon` # Watch and compile `.coffee` and `.styl` files in `/client` task "startdev", "Starts server with nodemon and watch files for changes", -&gt; # start nodemon server nodemon = spawn procExec("nodemon"), ["server.coffee"] processOutput nodemon # watch and compile CoffeeScript coffee = spawn procExec("coffee"), ["-o", "public/js/app", "-cw", "client/coffee"] processOutput coffee # watch and compile Stylus stylus = spawn procExec("stylus"), ["client/stylus", "-l", "-w", "-o", "public/css/app"] processOutput stylus </code></pre> <p>It works but with a few minor problems: </p> <ul> <li><code>npm install|update</code> doesn't seem to install <code>nodemon</code>. I think it tries to install globally and fails. I manually did a <code>npm install nodemon</code> separately. Why is this? And how can I tell <code>nodemon</code> to install anyway?</li> <li>Does <code>"./node_modules/.bin/" + procName</code> always resolve to the correct executable? </li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload