What / Why
Creating an unscoped alias of scoped package does not place bin files, the parent directory calculation incorrectly points to project directory.
var parent = pkg.name && pkg.name[0] === '@' ? path.dirname(path.dirname(folder)) : path.dirname(folder)
Tried to print parameters passed in, seems that _requested.name
contains the alias name I requested:
pkg: {
name: '@jixun/tape',
version: '4.13.1-patch3',
// -- snip --
_requested: Result {
type: 'alias', // install as alias
name: 'my-tape', // the name I want to use
escapedName: 'my-tape',
raw: 'my-tape@npm:@jixun/[email protected]',
// -- snip --
},
// -- snip --
}
My quick patch for v1.1.7
:
$ git diff
diff --git a/index.js b/index.js
index 79c2cb5..a06720a 100644
--- a/index.js
+++ b/index.js
@@ -23,7 +23,8 @@ function binLinks (pkg, folder, global, opts, cb) {
// if it's global, and folder is in {prefix}/node_modules,
// then bins are in {prefix}/bin
// otherwise, then bins are in folder/../.bin
- var parent = pkg.name && pkg.name[0] === '@' ? path.dirname(path.dirname(folder)) : path.dirname(folder)
+ var name = pkg._requested ? pkg._requested.name : pkg.name;
+ var parent = name && name[0] === '@' ? path.dirname(path.dirname(folder)) : path.dirname(folder)
var gnm = global && opts.globalDir
var gtop = parent === gnm
The 2.0.0
implementation changed. From my understanding it shouldn't cause any problems since the detection is done from a given installed path:
const scopeOrNm = dirname(path) // path should be pointing to "/path/to/node_modules/my-tape"
However, since the npm-cli still uses 1.1.6, does it make sense to create another 1.1.8
address this issue and notify npm-cli to use the new version?
When
Whenever I install a scoped package that has been aliased to use un-scoped name.
Where
node_modules/.bin
directory, [email protected]
How
Current Behavior
node_modules/.bin/tape
is not created.
Steps to Reproduce
$ npm i -D my-tape@npm:@jixun/tape@^4.13.1-patch3
Expected Behavior
node_modules/.bin
should contain executable for tape.
Who
References