How to change where spack installs package? - spack

Is there a way to have spack install software at a location of my choosing?
For example, if I do:
spack install netcdf-c
Then spack will install netcdf-c in a directory like:
/home/ed/spack/opt/spack/linux-ubuntu21.04-broadwell/gcc-10.3.0/netcdf-c-4.8.0-4zwtnn73atpc5ojmpigo7utmwzds7qrq
Is it possible to have spack install netcdf-c at /usr/local instead?

There are several ways to do this. The preferred way would be to make an environment and use a spack view to put the install (or symlink to the install binaries) where you want them.
If you wanted to hard code the install path this can be done as well through the spack config.yaml (documentation here; look at the install_tree:root ).

Related

Can I install node_modules once, and require all time

Same title.
I don't want install every time with any project.
Just install once.
Thanks in advance.
Edit: I know install global but how to require it is my question.
Check Addenda: Package Manager Tips
Define NODE_PATH with path local modules, example:
/usr/lib/node_modules
C:\Users\<Username>\AppData\Local\Yarn\Data\global\node_modules
Or anywhere you want
And now you can call it.
Since the module lookups using node_modules folders are all relative, and based on the real path of the files making the calls to require(), the packages themselves can be anywhere.
Yes. possible. Install all the modules globally.
ie; npm install -g <module_name>
Then use it in your application as necessary.
But, this method is not advised.
After you install them global, use npm link in project folder with package names(see npm link), to link them to that project. e.g. if your project requires lodash use npm link lodash.
Another way, if you want to have multiple little scripts(e.g. not projects) you can set the NODE_PATH variable with path to where your npm stores global packages. And after that require('<global-module>') will work without link and installing node_modules into folder.

how to use pre-installed binaries (zeromq) in npm install instead of build by node-gyp tool?

i am on alpine:3.6 i've already installed zeromq binary from (compiled from source) on system.
and now i want to use nodejs's binding for this.
so using https://github.com/JustinTulloss/zeromq.node
here is some instruction here in which we can build library from source.
https://github.com/JustinTulloss/zeromq.node/wiki/Installation#installation-on-linux--bsd-without-root-access
we can complie lib on our own but that places binaries in same folder, but instead i want npm to use library which installed in system (/use/local)
as far as i can gess its game of these two lines which i don't much knowledge about it
export CXXFLAGS="-I $(readlink -f ../include)"
export LDFLAGS="-L $(readlink -f ../lib) -Wl,-rpath=$(readlink -f ../lib)"
then npm install will use libs what we just complied in zeromq folder
i don't have much knowledge of CXXFLAGS and LDFLAGS so is that possible.
The installation instructions you cite are for peopel without root access, which are therefore unable to install software in the "usual places" like /usr or /usr/local. If you install a library into an "unusual place" like your home directory, you have to tell the compiler and linker where the library can be found. Thats the use of CXXFLAGS and LDFLAGS in this case. Since you seem to have root access and installed the ZeroMQ library in an "usual place", npm install zmq should work without you having the set these varaibales.
Update: The above seems to be not working. However, according to https://github.com/JustinTulloss/zeromq.node#project-status, this module is deprecated anyway. The new zeromq model works without compilation for me. See this minimal Dockerfile:
FROM node:alpine
RUN npm install zeromq
Note: This does not use the pre-installed library but a pre-build one instead. However, you could leave out the pre-installed library from the base image to save size.
it is possible now, with 6-beta.4, just tested
npm install zeromq#6.0.0-beta.4 --zmq-shared
in a system with zeromq package is installed, i.e. in alpine
apk add zeromq-dev
I am almost sure that -dev package is not required, but I did not tested
UPDATE (few minute later)
It is possible to use zmq as external library, it requires anyway a compilation, but without downloading all package.
Give that the zeromq-dev is installed
apk add zeromq-dev
(in this case -dev is required), then
npm i zeromq-stable --zmq-external
will compile the nodejs module, but not the zeromq library itself, a very faster option, but still not getting the lightweight docker image you need

copy npm global installed package to local

If I have a npm package installed globally, and I want to install the same package locally in some project, does npm download the package again or copy it from the global install folder? If not, is there a way to make it do that?
It is not recommended to copy files from global to local. It is pretty normal to have package installed in both places.
Global package in most of the cases is used in terminal.
Local package is used in application itself.
Also you can use npm link to symlink a global package
Install it in both places. Seriously, are you that short on disk
space? It’s fine, really. They’re tiny JavaScript programs.
Install it
globally, and then npm link coffee-script or npm link express (if
you’re on a platform that supports symbolic links.) Then you only need
to update the global copy to update all the symlinks as well.
The first option is the best in my opinion. Simple, clear, explicit. The
second is really handy if you are going to re-use the same library in
a bunch of different projects. (More on npm link in a future
installment.)

What does "npm install -g" do?

I am trying to install Less from NPM by running npm install -g less in the command line. I checked the docs for the install command:
In global mode (ie, with -g or --global appended to the command), it
installs the current package context (ie, the current working
directory) as a global package.
What does it mean by "global package"?
You are not required to install Less globally.
Installing it locally means the module will be available only for a specific project (the directory you were in when you ran npm install), as it installs to the local node_modules folder.
A global install will instead put the module into your global package folder (OS dependent), and allows you to run the included executable commands from anywhere. Note that by default you can only require local packages in your code.
See the node.js docs for more info on global vs local packages.
Generally speaking, you should install most modules locally, unless they provide a CLI command that you want to use anywhere.
In the end, I suggest you install less globally, as less provides an executable command that you will likely need in different projects. This is also what the Less docs recommend.
From: https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/
There are two ways to install npm packages:
globally —- This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in {prefix}/share/man, if they’re supplied.
locally —- This installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/, and man pages aren’t installed at all.
It simply means that the package you are installing while be available/integrated throughout your Nodejs platform.

Is there an alternative for npmzip?

As mentioned by #NS Gopikrishnan in this question there was an npmzip tool that we could use to create npm install packages that include all dependancies for that package.
Unfortunately npmzip is no longer available.
I would be very interested in creating offline install packages that include all dependancies. Does anyone know of an alternative to npmzip that does this for me?
According to #kamil's answer in this question there's indeed an alternative to npmzip. It is called npmbox
In online environment, npm install --no-bin-link. You will have a entire flattened node_modules
Then, bundle this flawless node_modules with tar / zip / rar / 7z etc
In offline environment, extract the bundle, that's it
P.S node-pac is another option, but it can't deal with the packages which still need downloading something for installation.

Resources