0

I've a package.json like this:

{
  "name": "some-module",
  "version": "1.0.0",
  "bin": "./bin/some-module.js",
  "main": "./bin/some-module.js",
  "description": "Some module description",
  "homepage": "http://my.home.page.com",
  "author": {
    "name": "Matias Fidemraizer",
    "email": "[email protected]",
    "url": "http://some.url.com"
  },
  "engines": {
    "node": ">=0.4.0"
  },
  "keywords": [
     "somekeyword"
  ],
  "license": {
    "type": "Apache v2",
    "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
  },
  "preferGlobal": true,
  "repository": {
    "type": "git",
    "url": "git://github.com/some/repo"
  },
  "dependencies": {
     "somedependency": "*"
  }
}

When I try to install the whole module typing npm -g install /path/to/module/folder, npm creates a .cmd file on AppData folder in the default node_modules location for global installations as expected.

But generated code doesn't include node.exe or node:

"%~dp0\node_modules\some-module\bin\some-module.js"   %*

... so when I try to execute my some-module module in CMD, PowerShell or whatever, it's executed using Windows Script Host (WSH).

For that reason I thought comparing package.json of some existing module like YUIDocJS would be enough to find out what's causing this problem but I can't figure out what's wrong in my own package.json so it doesn't create the expected global installation.

Thank you in advance for your effort.

1 Answer 1

2

Do you have the shebang #!/usr/bin/env node at the top of the file referenced in the bin property of your package.json? Even though the shebang is a *nix specific directive, npm depends on its presence to create the shim for the .cmd

Sign up to request clarification or add additional context in comments.

5 Comments

BTW, YuiDocJs package.json lacks this *nix reference!
Just to be clear: The shebang goes in the bin file, not the package.json... that is why YUIDocJS package.json doesn't have it
Yeah yeah, big mistake, sorry :)
You're right! This is the solution. Thank you, it worked! I was looking for diffs comparing package.json but I forgot to check the whole bin file.....!!
Its not well documented... I feel like it deserves a ticket on the github repo if you have the time =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.