[英]Scoped NPM Package binaries not added to PATH
Using new NPM private packages, with a scope package. 使用新的NPM私有软件包和范围软件包。 However, when installing, the projects bin is lo longer added to path.
但是,在安装时,项目容器将不再添加到路径中。
This works, with the tool available in the PATH. 可以使用PATH中提供的工具来工作。
{
name: 'hello',
bin: { 'hello':'hello.js' }
}
This does not work, once the scope has been added. 添加范围后,此操作将无效。
{
name: '@private/hello',
bin: { 'hello':'hello.js' }
}
Error is: 错误是:
-bash: /usr/local/bin/hello: No such file or directory
Does the bin path need to change? bin路径是否需要更改?
Update: What npm link
does: 更新:
npm link
是:
/usr/local/bin/hello -> /usr/local/lib/node_modules/@private/hello/hello.js
/usr/local/lib/node_modules/@private/hello -> /Path/To/HomeDirectory/SourceFolder.git
Seems to work for me. 似乎为我工作。
$ cat package.json
{"name":"@isaacs/foo","bin":{"foo":"foo.js"},"version":"1.2.3"}
$ npm link
/usr/local/bin/foo -> /usr/local/lib/node_modules/@isaacs/foo/foo.js
/usr/local/lib/node_modules/@isaacs/foo -> /Users/isaacs/dev/js/x/scopebin
$ foo
foo
$ cat $(which foo)
#!/usr/bin/env node
console.log("foo")
$ ls -laF $(which foo)
lrwxr-xr-x 1 isaacs admin 38 Jun 22 15:55 /usr/local/bin/foo@ -> ../lib/node_modules/@isaacs/foo/foo.js
$ ls -laF /usr/local/lib/node_modules/@isaacs/foo
lrwxr-xr-x 1 isaacs admin 31 Jun 22 15:55 /usr/local/lib/node_modules/@isaacs/foo@ -> /Users/isaacs/dev/js/x/scopebin
Of course, if you use just "bin":"foo.js"
in your package.json, then the default mechanism of turning that into "bin":{<package name>:"foo.js"}
won't work, because the <package name>
has a /
in it. 当然,如果在package.json中仅使用
"bin":"foo.js"
,则将其转换为"bin":{<package name>:"foo.js"}
的默认机制将不起作用,因为<package name>
中带有/
。
$ npm link
/usr/local/bin/@isaacs/foo -> /usr/local/lib/node_modules/@isaacs/foo/foo.js
/usr/local/lib/node_modules/@isaacs/foo -> /Users/isaacs/dev/js/x/scopebin
Since /usr/local/bin/@isaacs
isn't in my PATH
, it won't work as expected. 由于
/usr/local/bin/@isaacs
不在我的PATH
,因此无法正常工作。
$ foo
bash: foo: command not found
This is using the latest and greatest npm. 这使用的是最新的最大npm。 YMMV if you're using something older.
YMMV,如果您使用的是旧版本。
$ npm -v
2.12.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.