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

fpm's npm mode hardcodes modules to go in /usr/local/lib/node_modules #758

Closed
uberbrady opened this issue Aug 20, 2014 · 8 comments
Labels
npm

Comments

@uberbrady
Copy link

@uberbrady uberbrady commented Aug 20, 2014

My particular copy of Node was configured with a prefix of /usr, so it expects global modules to be in /usr/lib, not /usr/local/lib

Ideally, this would not be a command-line option, but something we could introspect out of the npm or node binaries. Worst-case scenario, maybe you can determine it from the path of node - e.g. if your copy of node is in /usr/bin/node, then you know your libraries should be in /usr/lib/node_modules, whereas if your copy of node is in /usr/local/bin/node, then you know your libraries ought to be in /usr/local/lib/node_modules

@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Aug 21, 2014

I'm scouring the nodejs docs for some kind of hint as to where I could learn where the default NODE_PATH is, but am coming up empty. I'll check the npm code.

@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Aug 21, 2014

@uberbrady what's the output of npm prefix -g on your systems? Specifically, the one you are building the package on, and the one you are deploying on?

@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Aug 21, 2014

> npm.config.get("prefix")
'/usr/local'
@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Aug 21, 2014

So! Here's what I think. maybe.

We can automatically set the prefix in the RPM to the npm prefix so that you get a relocatable RPM. I don't know how we'll really do the installation dynamically for the target system, yet, though.

@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Aug 21, 2014

You can hardcode --prefix at package-creation time and it follows through to fpm's invocation of npm:

% fpm -s npm -t rpm --prefix /tmp/fancypants ofe
no value for epoch is set, defaulting to nil {:level=>:warn}
no value for epoch is set, defaulting to nil {:level=>:warn}
Created package {:path=>"node-ofe-0.1.2-1.x86_64.rpm"}
% rpm -qlp node-ofe-0.1.2-1.x86_64.rpm
/tmp/fancypants/lib/node_modules/ofe/.npmignore
/tmp/fancypants/lib/node_modules/ofe/README.md
/tmp/fancypants/lib/node_modules/ofe/binding.gyp
...

Under fpm --debug you'll see:

Running command {:args=>["npm", "install", "ofe", "--cache", "/tmp/package-npm-build20140821-22959-bi9ga6/npm_cache", "--loglevel", "warn", "--global", "true", "--prefix", "/tmp/package-npm-staging20140821-22959-6oae0z/tmp/fancypants"], :level=>:debug, :file=>"fpm/util.rb",
 :line=>"59"}

Best I can tell, for right now, we have a workaround for you via --prefix (in your case, --prefix /usr)

@uberbrady

This comment has been minimized.

Copy link
Author

@uberbrady uberbrady commented Aug 21, 2014

Thanks a billion for the help, sir.

I've been able to workaround my problem with a combination of things; your things and my things too.

So my 'problem' is, for now, solved. But I bet we still want to do a fix for fpm itself too.

@r4um r4um added the npm label Aug 22, 2014
@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Oct 25, 2014

We can automatically set the prefix in the RPM to the npm prefix so that you get a relocatable RPM

I propose we set the result of npm prefix -g to the default fpm prefix unless --prefix is specified.

@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Oct 25, 2014

% rpm -qip node-express-4.10.0-1.x86_64.rpm | grep Reloc
Relocations : /usr/local
prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 18, 2014
prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 27, 2014
jordansissel added a commit that referenced this issue Apr 24, 2015
jordansissel added a commit that referenced this issue Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.