global cli npm 包适用于 windows 但不适用于 linux

global cli npm package works on windows but not linux

我想创建一个 npm cli 工具,我研究了 bower 的代码并复制了它们的基本 package.json 以及 bin 和 lib/bin 文件。

在 windows 上运行完美,但在 linux 上我只得到 : No such file or directory

npm 包是:https://www.npmjs.com/package/quilk

这里是代码,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.');

在 windows 上全局安装它的最终结果是 console.log 是 运行 在我简单地键入 quilk 后输出是 This is the quilk script.

在 Ubuntu 14lts 上,尝试 运行 新的全局安装的 npm 模块导致 : No such file or directory

的输出

我错过了什么才能在 linux 上获得这个 运行?

(当我 运行 列出全局安装的 npm 模块的命令时 npm ls -g quilk 被列出)

更多信息: 我在以下版本中遇到完全相同的问题:

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

我找到了答案。

事实证明是 windows 10.

上 npm 的某种错误

从 linux 盒子发布相同的包后,npm 包现在可以在 linux 和 windows 上运行,这让我相信 npm 在 windows 上发布某处有一些错误。

报告的问题:https://github.com/npm/npm/issues/13808