[英]why the command script generated for my npm package is different than other package?
I published a npm package myself: makeTimeTable 我自己发布了一个npm包: makeTimeTable
I installed it happily in cygwin: 我在cygwin中愉快地安装了它:
npm install -g maketimetable
But when I try to run the command line, an error is thrown: 但是,当我尝试运行命令行时,会引发错误:
/node_modules/maketimetable/cli.js: No such file or directory
Finally I figure out that the command script file( C:\\Users\\xxx\\AppData\\Roaming\\npm\\maketimetable
) generated when installing my package is different than other global command line tools I installed, below is mine: 最后,我发现安装软件包时生成的命令脚本文件(
C:\\Users\\xxx\\AppData\\Roaming\\npm\\maketimetable
)与我安装的其他全局命令行工具不同,以下是我的:
"$basedir/node_modules/maketimetable/cli.js" "$@"
exit $?
other global command line tools' script is like this: 其他全局命令行工具的脚本如下所示:
#!/bin/sh
basedir=`dirname "$0"`
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/node_modules/eslint/bin/eslint.js" "$@"
ret=$?
else
node "$basedir/node_modules/eslint/bin/eslint.js" "$@"
ret=$?
fi
exit $ret
So in other tools' script, it will distinguish whether I'm using cygwin, it will treat the path and directory a little differently. 因此,在其他工具的脚本中,它将区分我是否正在使用cygwin,它将对路径和目录进行一些不同的处理。 But why my package's script is different than those?
但是,为什么我的软件包的脚本不同于那些脚本? How can I make npm to generate the same kind of script for my package?
如何使npm为我的包生成相同类型的脚本?
尝试将#!/usr/bin/env node
作为cli.js
的第一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.