Skip to content

Commit

Permalink
[fix] Downgrade npm for Git submodule support
Browse files Browse the repository at this point in the history
`npm install` used to `git clone --recursive` the things that it builds out of GitHub; but it [doesn't do that anymore](npm/cli#2774). Unfortunately, we depend on that feature, because a submodule is how https://github.com/Level/rocksdb pulls in the Facebook code.

This fixes a really absconse error message, which is a huge pain to debug BTW:

```
npm ERR! make: *** No rule to make target 'Release/obj.target/rocksdb/deps/rocksdb/rocksdb/cache/cache.o', needed by 'Release/obj.target/deps/rocksdb/rocksdb.a'.  Stop.
```

(That's because there's no source code under `deps/rocksdb/rocksdb`, on account of that directory being a Git submodule.)

It seems... difficult to convince npm to keep its temporary files for inspection. I had to temporarily push a hacked `package.json` into the `master` branch of `epfl-si/rocksdb-node`, with an `install` script entry that reads

```
    "install": "node-gyp-build || (sleep 3600; exit 1)",
```

Confusingly enough, modern `npm`s will do the right thing (i.e. pull the submodules) when one runs e.g. `npm i -g epfl-si/rocksdb-node`; but not when said `epfl-si/rocksdb-node` is a dependency in a `package.json`, as is the case here. Go figure.
  • Loading branch information
Dominique Quatravaux committed Mar 1, 2023
1 parent 9289a5a commit 974e7d9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:18-alpine AS common

WORKDIR /app

COPY package*.json ./
Expand All @@ -7,6 +8,9 @@ FROM common AS build

RUN apk add python3 git make g++ linux-headers

# SIGH. https://github.com/npm/cli/issues/2774
RUN npm install -g npm@'^6.4.11'

RUN npm install
COPY . ./
RUN npm run build
Expand Down

0 comments on commit 974e7d9

Please sign in to comment.