node.js - npm-generated command not calling node -


i'm trying create node.js command line utility , having issue wrapper npm generates. super-simple demo package.json file:

{     "name": "demo-cli",     "version": "0.0.1",     "bin": { "demo": "bin/demo-cli.js" } } 

and demo-cli.js file:

console.log('demo worked'); 

the issue when install module using npm install -g while in project directory wrapper generates not call node file parameter. generated contents of demo.cmd:

:: created npm, please don't edit manually. "%~dp0\.\node_modules\demo-cli\bin\demo-cli.js"   %* 

the unix version has same issue. looking @ globally installed cli can see node being tested , called expected.

:: created npm, please don't edit manually. @if exist "%~dp0\node.exe" (   "%~dp0\node.exe"  "%~dp0\.\node_modules\mocha\bin\mocha" %* ) else (   node  "%~dp0\.\node_modules\mocha\bin\mocha" %* ) 

what secret sauce needed npm generate proper script file? i've tried find or think of, including removing .js extension, preferring global, specifying node version...no luck.

i'm using node v0.6.18 , npm v1.1.21 on windows 7 x64.

try putting

#!/usr/bin/env node 

at top of demo-cli.js file.

on windows, npm looks shebang line when creating .cmd wrapper. see cmd-shim.js in npm source more info.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -