Giter Site home page Giter Site logo

Comments (30)

jasonkarns avatar jasonkarns commented on April 28, 2024 3

I would suggest following the XDG base directory spec

AFAIK, everything in ~/.node-gyp is cache data, so I would propose $XDG_CACHE_HOME/node/gyp. If anything qualifies as "appdata" then $XDG_DATA_HOME/node/gyp

from node-gyp.

absolutelynothelix avatar absolutelynothelix commented on April 28, 2024 2

oh, so it was implemented? sorry, looked through readme, source code and several posts in this issue since i'm not working with node-gyp and something that i built created this directory and i just wanted to prevent this in future. ok, i'll try that, thanks!

from node-gyp.

Soares avatar Soares commented on April 28, 2024 1

I'd suggest just using process.env.XDG_CONFIG_HOME || process.env.HOME as a simple solution.

from node-gyp.

mojodna avatar mojodna commented on April 28, 2024 1

👍

npm's cache config is along the lines of what I'd expect here: https://npmjs.org/doc/cli/npm-cache.html#CONFIGURATION

(Context: persistent node-gyp cache on Heroku between builds.)

from node-gyp.

jcrben avatar jcrben commented on April 28, 2024 1

Does npm support npm_config_devdir? I tried to test it using a recent npm version (3.10.3) by reinstalling all my global packages but not really sure how all this stuff is tied together... installing a bunch of packages did not generate anything new in my .node-gyp file.

from node-gyp.

develar avatar develar commented on April 28, 2024 1

Since electron-builder 18.4.0 ugly solution HOME env will be not used anymore. Because in this case cache dir is doubled (yarn and npm have to download and cache deps twice). Thanks! --devdir and npm_config_devdir works in my tests. I will risk to roll out this update to users. Thanks again that now node-gyp allows to set devdir.

from node-gyp.

TooTallNate avatar TooTallNate commented on April 28, 2024

Could probably add a --dev-dir flag or something real quick.

from node-gyp.

apaprocki avatar apaprocki commented on April 28, 2024

Getting hit by this because I'm behind a proxy which doesn't allow GET from nodejs.org. It would be great to support a -g option to install globally similar to npm install -g and node-gyp would simply look in the global dir first before the home dir.

from node-gyp.

TooTallNate avatar TooTallNate commented on April 28, 2024

@apaprocki This option would still require you to download node header files, this would just be where to store them. I think what you're looking for is the --nodedir option, which can be used to specify the location of a node source tree to compile the addon against (that option already exists).

from node-gyp.

apaprocki avatar apaprocki commented on April 28, 2024

@TooTallNate Yes, --nodedir would be useful. Above, I was thinking about the case where an admin (or user with sufficient proxy privileges) would install the dev files in the global dir so that every user on the machine does not need to download/install a local copy in their home dir.

from node-gyp.

TooTallNate avatar TooTallNate commented on April 28, 2024

@apaprocki Ok I see what you mean now. Yes, could do what you are describing with this proposed --devdir flag. Frankly, it should be pretty easy if anyone feels like whipping up a patch.

from node-gyp.

mindon avatar mindon commented on April 28, 2024

suggest detecting NODE_ROOT variable in env variables as nodeDir when there's no --nodedir

if ( gyp.opts.nodedir || process.env.NODE_ROOT ) {
  // --nodedir was specified. use that for the dev files
  nodeDir = gyp.opts.nodedir ? gyp.opts.nodedir.replace(/^~/, osenv.home()) : process.env.NODE_ROOT

  log.verbose('get node dir', 'compiling against specified --nodedir dev files: %s', nodeDir)
  createBuildDir()
 } else {
  // ....
 }

then we don't need to configure with --nodedir every time

from node-gyp.

mroch avatar mroch commented on April 28, 2024

@TooTallNate: what do you think of @mindon's proposal? I can send a pull request...

We'd appreciate this change here at Facebook. Our build process is pretty crazy. Being able to set an environment variable is preferable to a flag for us because npm defaults to node-gyp rebuild, and some modules have the node-gyp command hardcoded, making it impossible to override the default args without patching their package.json.

from node-gyp.

zcbenz avatar zcbenz commented on April 28, 2024

@TooTallNate: Any news on this? I just hit this problem while building native modules against my custom headers, if there is something like --nodedir or an environment variable then I don't need to fork node-gyp.

from node-gyp.

TooTallNate avatar TooTallNate commented on April 28, 2024

The --nodedir flag is there

On Tuesday, February 19, 2013, Cheng Zhao wrote:

@TooTallNate https://github.com/TooTallNate: Any news on this? I just
hit this problem while building native modules against my custom headers,
if there is something like --nodedir or an environment variable then I
don't need to fork node-gyp.


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-13774715.

from node-gyp.

zcbenz avatar zcbenz commented on April 28, 2024

Oops, I meant --devdir. Using --nodedir will assume headers are already downloaded and will skip the install step, I think a flag like --devdir is still needed.

from node-gyp.

TooTallNate avatar TooTallNate commented on April 28, 2024

Well you can kinda hack it at the moment by setting the HOME env variable, but a proper patch adding --devdir would be accepted as well.

from node-gyp.

charlieok avatar charlieok commented on April 28, 2024

I love the way npm handles config params:
https://npmjs.org/doc/config.html

Same values can be set via flags, env vars, per-user files, global files, builtins set by ./configure params, and defaults. It even provides commands a script can use to create and populate the config files (which is what I ended up doing, but I could have also set up vars or managed the configs in version control). Wish more software were so flexible in this regard.

I'm putting together a build process that wraps a large collection of various software packages. node/npm was a breeze because of its flexible options. Right now node-gyp is sticking out like a sore thumb because of the ~/.node-gyp directory it's leaving behind when I don't want anything in $HOME.

from node-gyp.

toolness avatar toolness commented on April 28, 2024

Hey, just wanted to mention that I'm installing bcrypt as part of a user-data script on Amazon EC2, which uses node-gyp to compile some binaries. However, because node-gyp expects either HOME or USERPROFILE to be defined in the environment, and EC2 doesn't set either of these environment variables itself when running the userdata script as root, the installation fails with the following traceback:

path.js:313
        throw new TypeError('Arguments to path.resolve must be strings');
              ^
TypeError: Arguments to path.resolve must be strings
    at Object.exports.resolve (path.js:313:15)
    at new Gyp (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:49:22)
    at gyp (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:39:10)
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:20:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

I was able to resolve this by defining HOME in my script, but it took me a while to figure this out. Perhaps this story can be used as a use-case in figuring out a solution to this problem--or at the very least, perhaps someone who stumbles into the same problem as me finds this comment in the future helpful.

from node-gyp.

terinjokes avatar terinjokes commented on April 28, 2024

We'd like our build boxes to be self-contained from external systems, and that includes nodejs.org. We can easily package up the node headers alongside our package of node, but we don't have any way of configuring node-gyp to using it, short of symlinking in ~/.node-gyp, which is a bit dirty. I'd would be happy with setting an ENV variable that sets the node header path.

from node-gyp.

rafi avatar rafi commented on April 28, 2024

Until you guys decide, it'll be great if you offer an environment variable or npm style config, e.g.

cache  = ${XDG_CACHE_HOME}/node-gyp

:)

from node-gyp.

dantran avatar dantran commented on April 28, 2024

where are we with this issue??. Dont meant to brag, but the discusion started in 2012 :-) and there is PR

from node-gyp.

codyps avatar codyps commented on April 28, 2024

Having an env-var as @mindon suggested would be useful for me as well. Not clear how to adjust the way npm calls node-gyp.

from node-gyp.

terinjokes avatar terinjokes commented on April 28, 2024

@TooTallNate echoing @jmesmon I don't know of a good way to change how npm calls node-gyp for me to add the --nodedir header. Can we get this as an environment option?

ninja-edit: Per npm-install this can be done by passing --nodedir to npm install.

from node-gyp.

bnoordhuis avatar bnoordhuis commented on April 28, 2024

@terinjokes You can pass --nodedir to npm and npm will pass it on to node-gyp. Alternatively, you can set npm_config_nodedir=/path/to/sources in the environment.

from node-gyp.

terinjokes avatar terinjokes commented on April 28, 2024

@bnoordhuis I had just edited my comment to point that out.

from node-gyp.

bnoordhuis avatar bnoordhuis commented on April 28, 2024

It should. npm passes on options it doesn't consume itself.

from node-gyp.

jcrben avatar jcrben commented on April 28, 2024

never ended up figuring out how this works - I suppose I might dig into the code someday... these were the steps, expecting node 8.9.1 with npm 5.5.1 executingnpm install -g node-gyp to put ~/.node-gyp into the devdir (which I'm setting with export npm_config_devdir="$XDG_CACHE_HOME"/.node-gyp in my .bashrc on macOS 10.12.16
image

@jasonkarns fyi, for me, it doesn't seem like ~/.node-gyp is cache data - it's got include files and stuff to run applications, I suppose in XDG it would end up in XDG_DATA_HOME or something

from node-gyp.

absolutelynothelix avatar absolutelynothelix commented on April 28, 2024

node-gyp/lib/node-gyp.js

Lines 41 to 45 in 470f04e

// set the dir where node-gyp dev files get installed
// TODO: make this configurable?
// see: https://github.com/TooTallNate/node-gyp/issues/21
var homeDir = process.env.HOME || process.env.USERPROFILE
this.devDir = path.resolve(homeDir, '.node-gyp')

found this issue while digging the source code on how it works. yeah, can we have a environment variable or something to move this folder? i don't want to keep this at my home folder and i've already moved almost anything in corresponding folders ($XDG_CONFIG_HOME, $XDG_CACHE_HOME and $XDG_DATA_HOME)

from node-gyp.

richardlau avatar richardlau commented on April 28, 2024

@mighty9245 You should be able to use the --devdir parameter if manually invoking node-gyp or set the npm_config_devdir environment variable to change the folder.

from node-gyp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.