简体   繁体   中英

global cli npm package works on windows but not linux

I am wanting to create an npm cli tool, I dug around in bower's code and replicated their basic package.json along with the bin and lib/bin file.

On windows it works perfectly, but on linux I just get : No such file or directory

The npm package is: https://www.npmjs.com/package/quilk

Here is the code, package.json :

  {
  "name": "quilk",
  "version": "0.1.3",
  "description": "quilk.",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "John Carmichael",
  "keywords": [
    "builder", "watcher", "fast", "quilk"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/johnc1984/quilk"
  },
  "main": "lib",
  "bin": {
    "quilk": "bin/quilk"
  },
  "files": [
    "bin",
    "lib"
  ],
  "homepage": "https://github.com/johnc1984/quilk",
  "engines": {
    "node": ">=0.10.0"
  },

  "dependencies": {
    "browserify"              : "13.1.0",
    "concat-files"            : "0.1.0",
    "chokidar"                : "1.6.0",
    "fs.extra"                : "1.3.2",
    "javascript-natural-sort" : "0.7.1",
    "jdc-node-cliarg-reader"  : "1.0.0",
    "less"                    : "2.7.1",
    "node-notifier"           : "4.6.1",
    "node-minify"             : "1.3.9",
    "q"                       : "1.4.1",
    "recursive-readdir"       : "2.0.0"
  }
}

bin/quilk :

#!/usr/bin/env node

require('../lib/bin/quilk');

lib/bin/quilk

process.bin = process.title = 'quilk';

console.log('This is the quilk script.');

The end result of installing this globally on windows is the console.log is run on the output is This is the quilk script. after i simply type quilk .

On Ubuntu 14lts though, trying to run the freshly, globally installed npm module results in the output of : No such file or directory

What am I missing to get this run on linux?

(when i run the command to list the globally installed npm modules npm ls -g quilk is listed)

Further info: I get the exact same issue on the following builds:

  1. Ubuntu 14lts, node 6.4.0, npm 3.10.3
  2. Debian 6.0.10, node 0.12.7, npm 2.11.3

I found the answer.

It turns out to be some kind of bug in npm on windows 10.

After publishing the same package from a linux box, the npm package now works on both linux and windows leading me to believe that npm publish on windows has some bug in it somewhere.

Issue reported: https://github.com/npm/npm/issues/13808

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM