Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node_module's bin folder of window is in '/server/' issue. #69

Closed
coconutperm opened this issue Feb 6, 2017 · 5 comments
Closed

node_module's bin folder of window is in '/server/' issue. #69

coconutperm opened this issue Feb 6, 2017 · 5 comments
Assignees

Comments

@coconutperm
Copy link
Collaborator

coconutperm commented Feb 6, 2017

When install npm package, npm binary file is in /server/ folder to window os.

I guess npm path refer global bin directory like below.

nodejs/.../gently-rm-linked-modules.js

  var globalBin = resolve(linkedGlobal, isWindows ? '.' : 'bin', 'linked')
  // on window os, use path '.' this is concept for nodejs.

  var globalModule = resolve(linkedGlobal, isWindows ? '.' : 'lib', 'node_modules', '@test', 'linked')
  var localBin = resolve(workingDir, 'node_modules', '.bin', 'linked')
  var localModule = resolve(workingDir, 'node_modules', '@test', 'linked')

nodejs/.../build.js

// 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 gnm = global && npm.globalDir
var gtop = parent === gnm

function linkBins (pkg, folder, parent, gtop, cb) {
console.log("TWHY : linkBins parent=" + parent + ", gtop=" + gtop); //<--- gtop is true;
if (!pkg.bin || !gtop && path.basename(parent) !== 'node_modules') {
return cb()
}
var binRoot = gtop ? npm.globalBin //<--- use globanBin path.
: path.resolve(parent, '.bin')

I don't know why 'gtop' value is true. need more survey.

@coconutperm
Copy link
Collaborator Author

https://github.com/npm/npm/blob/latest/lib/install.js

200 function Installer (where, dryrun, args) {
201 validate('SBA', arguments)
202 this.where = where
203 this.dryrun = dryrun
204 this.args = args
205 this.currentTree = null
206 this.idealTree = null
207 this.differences = []
208 this.todo = []
209 this.progress = {}
210 this.noPackageJsonOk = !!args.length
211 this.topLevelLifecycles = !args.length
212 this.dev = npm.config.get('dev') || (!/^prod(uction)?$/.test(npm.config.get('only')) && !npm.config.get('production')) || /^dev(elopment)?$/.test(npm.config.get('only'))
213 this.prod = !/^dev(elopment)?$/.test(npm.config.get('only'))
214 this.rollback = npm.config.get('rollback')
215 this.link = npm.config.get('link')
216 this.global = this.where === path.resolve(npm.globalDir, '..')
217 }

228 // FIXME: This is bad and I should feel bad.
229 // lib/install needs to have some way of sharing limited
230 // state with the things it calls. Passing the object is too
231 // much. The global config is WAY too much. =( =(
232 // But not having this is gonna break linked modules in
233 // subtle stupid ways, and refactoring all this code isn't
234 // the right thing to do just yet.
235 if (this.global) {
236 var prevGlobal = npm.config.get('global')
237 npm.config.set('global', true)
238 var next = cb
239 cb = function () {
240 npm.config.set('global', prevGlobal)
241 next.apply(null, arguments)
242 }
243 }

This is problem. it's known issue. if it same where with globalDir, set force true.

@coconutperm
Copy link
Collaborator Author

FIXME: This is bad and I should feel bad.
lib/install needs to have some way of sharing limited state with the things it calls. Passing the object is too much. The global config is WAY too much. =( =(
But not having this is gonna break linked modules in subtle stupid ways, and refactoring all this code isn't the right thing to do just yet.

@coconutperm
Copy link
Collaborator Author

216 this.global = this.where === path.resolve(npm.globalDir, '..')

if set --prefix option, then globalDir value set 'prefix/node_modules' folder always.
So, this is --prefix option bug.

@coconutperm
Copy link
Collaborator Author

coconutperm commented Feb 7, 2017

We cannot control this issue. I will report to npm repo.
npm/npm#15692

@coconutperm coconutperm self-assigned this Feb 9, 2017
romandev added a commit that referenced this issue Feb 23, 2017
This CL includes the follwing things.
 - Improve existing scripts.
 - Introduce |absolute| command for all platforms.
 - After this patch, we can add a new subcommand easily in bootstrap/command/.
 - Introduce very simple platform test. The test will be more improved later.
 - Fix a bug that executable files are located in server/ on windows (#69).
 - Remove unnecesary script parts in package.json
 - Stop to use nodemon until fixing it (#71)
romandev added a commit that referenced this issue Feb 23, 2017
This CL includes the follwing things.
 - Improve existing scripts.
 - Introduce |absolute| command for all platforms.
 - After this patch, we can add a new subcommand easily in bootstrap/command/.
 - Introduce very simple platform test. The test will be more improved later.
 - Fix a bug that executable files are located in server/ on windows (#69).
 - Remove unnecesary script parts in package.json
 - Stop to use nodemon until fixing it (#71)
romandev added a commit that referenced this issue Feb 23, 2017
This CL includes the follwing things.
 - Improve existing scripts.
 - Introduce |absolute| command for all platforms.
 - After this patch, we can add a new subcommand easily in bootstrap/command/.
 - Introduce very simple platform test. The test will be more improved later.
 - Fix a bug that executable files are located in server/ on windows (#69).
 - Remove unnecesary script parts in package.json
 - Stop to use nodemon until fixing it (#71)
@romandev
Copy link
Member

#73

romandev added a commit that referenced this issue Sep 30, 2017
This CL includes the follwing things.
 - Improve existing scripts.
 - Introduce |absolute| command for all platforms.
 - After this patch, we can add a new subcommand easily in bootstrap/command/.
 - Introduce very simple platform test. The test will be more improved later.
 - Fix a bug that executable files are located in server/ on windows (#69).
 - Remove unnecesary script parts in package.json
 - Stop to use nodemon until fixing it (#71)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants