Re: npm install, ports and poudriere

From: Hiroo Ono (小野寛生) <>
Date: Fri, 13 Jan 2023 12:00:50 UTC
Thank you.

2023年1月13日(金) 18:14 Tomoaki AOKI <>:
> On Fri, 13 Jan 2023 11:30:09 +0900
> Hiroo Ono (小野寛生) <> wrote:
> > Hello,
> >
> > I made a port of MongoDB Compass .
> > As it is an electron app, I need to use "npm install" to build it.
> >
> > npm install does not work without network connection, while poudriere
> > allow network connection only at fetch time.
> > As a result, I need to do bunch of things in fetch mode, and the
> > Makefile became as attached. Is this acceptable as a port?
> > If not, I need to rework the Makefile to do npm install at build time,
> > but that makes the port not officially buildable I think. (though to
> > each of us, there is ALLOW_NETWORKING_PACKAGES option in
> > poudriere.conf)
> Can editors/vscode be any hint? It's electron app, too.

editors/vscode helped me very much when I wrote the Makefile, but it
uses yarn which has the cache mechanism.
The problem is that "npm install" always try to connect to network
even if the package's tgz file is cached.
So I have to eliminate all the "npm install" after fetch target.
What I am doing is similar to what Emanuel Haupt suggested to me.
Doing "npm install" at post-fetch time, and backup node_modules directories,
and extract them at post-extract target.
(Else, WRKDIR is wiped away at the beginning of extract target.)

Every npm package is run "npm run install" with "npm install" and some packages
require cc, perl, python, rust, go and other things.
Thus, FETCH_DEPENDS became like this:

FETCH_DEPENDS=  git:devel/git \
                npm-node${NODE_VER_MAJOR}>0:www/npm-node${NODE_VER_MAJOR} \
                cmake:devel/cmake-core \
                pkg-config:devel/pkgconf \
                ${PYTHON_VERSION}:lang/python${PYTHON_SUFFIX} \
                cargo:lang/rust \
                # yarn:www/yarn-node${NODE_VER_MAJOR} \
                ${PREFIX}/lib/ \
.  else
.  endif

It requires not only npm, but also cmake, pkgconf, git, python, rust
to build and some libraries to be linked
in "npm run install".
(The dependency to yarn is just a residue of the trial to use yarn's
cache feature.)
Is it ok or running cc and rust should be avoided at fetch time? is
what I wanted to ask.
It can be avoided with "npm install --ignore-scripts", but I have to
run "npm run install" with each
npm package myself solving whole the dependency tree.
There are still things to do in do-build target. Not all the build
things are done in post-fetch.

So, I want to do "npm install" without "--ignore-scripts" in
post-fetch target. If I have to do
"npm run installs" in pre-build or do-build,  in the order I have to
determine digging all the package.json's.

> I'm not at all familiar with electron nor Node.js, but is there any
> cache mechanism for npm that can store required files into before
> install (at `make fetch` phase)? Does below be of any help?
> --
> Tomoaki AOKI    <>