Comments (30)
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.
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.
I'd suggest just using process.env.XDG_CONFIG_HOME || process.env.HOME
as a simple solution.
from node-gyp.
👍
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.
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.
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.
Could probably add a --dev-dir
flag or something real quick.
from node-gyp.
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.
@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.
@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.
@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.
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.
@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.
@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.
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.
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.
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.
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.
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.
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.
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.
where are we with this issue??. Dont meant to brag, but the discusion started in 2012 :-) and there is PR
from node-gyp.
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.
@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.
@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.
@bnoordhuis I had just edited my comment to point that out.
from node-gyp.
It should. npm passes on options it doesn't consume itself.
from node-gyp.
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
@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.
Lines 41 to 45 in 470f04e
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.
@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)
- mac sqlite3 system lib fmdb HOT 2
- node-gyp fails on Sonoma with CLI only and not XCode (Mac M1 / Apple Silicon) HOT 11
- node-gyp verison used when npm -install are not align to installed node-gyp version HOT 1
- msvs_version option seems ineffectual in selecting correct msbuild.exe HOT 4
- node-gyp keep downloading header even there is cache
- M2 yarn install failed? HOT 4
- Why gyp is using unofficial-builds.nodejs.org to download node-headers ? HOT 1
- cannot install better-sqlite3 HOT 2
- Mutable default arguments in Python code HOT 1
- tar.Extract is not a function HOT 2
- find-python broke with 18.20.0 (?) on ARM HOT 5
- gyp ERR! UNCAUGHT EXCEPTION gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT
- [Request] Upgrade tar to v6.2.1 HOT 6
- test/test-find-visualstudio.js may fail on Windows on ARM
- complie_commands.json generated by node-gyp doesn't be in clangd search path. HOT 6
- generate compile_commands.json automatically
- Generate .gitignore and .hgignore in build
- Customize default generator
- error when using node-gyp from yarn command HOT 3
- node-gyp `binding.gyp not found` error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-gyp.