Building Mailspring 10.2.1

Hello, since Mailspring updated npm version I have not been able to use the version that I built locally. I.e. I can run it with “npm start” but if I build the deb package and install it I get a non-functional Mailspring installation. The electron window opens, but it immediatly launches the developement interface with this error in the log:

index.js:26 Error: Cannot find module ‘app-module-path’
Require stack:

  • /usr/share/mailspring/resources/app.asar/src/app-env.js
  • /usr/share/mailspring/resources/app.asar/src/secondary-window-bootstrap.js
  • /usr/share/mailspring/resources/app.asar/static/index.html
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at Function.o._resolveFilename (node:electron/js2c/renderer_init:33:1095)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Function.o._load (node:electron/js2c/renderer_init:33:356)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at new AppEnvConstructor (file:///tmp/nylas-build/electron-packager/linux-x64/mailspring-linux-x64/resources/app/src/app-env.ts:65:5)
    at Object. (file:///tmp/nylas-build/electron-packager/linux-x64/mailspring-linux-x64/resources/app/src/secondary-window-bootstrap.ts:30:17)
    at Object. (file:///tmp/nylas-build/electron-packager/linux-x64/mailspring-linux-x64/resources/app/src/secondary-window-bootstrap.ts:38:49)
    at Module._compile (node:internal/modules/cjs/loader:1116:14)
    at Object.Module._extensions…js (node:internal/modules/cjs/loader:1169:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Function.o._load (node:electron/js2c/renderer_init:33:356)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at setupWindow (file:///usr/share/mailspring/resources/app.asar/static/index.js:46:3)
    at window.onload (file:///usr/share/mailspring/resources/app.asar/static/index.js:74:5)

It is probably me doing something wrong, but I am totally noob with electron, maybe someone can help me.
Some more detail: the version of npm that comes with Ubutu 20.04 is too old to run Mailspring 10.2.x:
/usr/bin/node --version
v10.19.0
For this reason, I installed a local node with nvm:
which node
/home/paulatto/.nvm/versions/node/v14.19.1/bin/node

I also install the required dependencies of Mailspring with “npm install”.

Maybe it is just a matter of selecting the correct version of node to use, but it is not documented anywhere? I also get a little warning when I run “npm install”:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I’ll try to do my best with it!

Seems like an issue with your node version. Mailspring is really picky with those things. Here is the versions, I am using on my Ubuntu 21.10 machine.

➜  Mailspring git:(master) nvm --version
0.39.0
➜  Mailspring git:(master) node --version
v16.13.0
➜  Mailspring git:(master) npm --version
8.1.0

I hope, this helps.

[0|19:48|naquite|Mailspring]$ nvm --version
0.39.1
[0|19:52|naquite|Mailspring]$ node --version
v16.14.2
[0|19:52|naquite|Mailspring]$ npm --version
8.5.0

Not so far away… I would be surprised if this was the cause. I’ll try to use your exact ones and report back

Edit: no, it does not work.

Edit 2: but I have noticed that when it builds it says

Packaging app for platform linux x64 using electron v17.1.1

Edit 3: I suspect it has something to do with this revert:

Solved: reverting the Revert “Revert” did the trick.

Did you do a fresh npm install after pulling the commit that upgraded the electron version?

The app-module-path is a module that is needed after the electron upgrade. So if you missed an npm install the npm start might work if the code is not run as the static files are not packed (with this asar thingy), but break after the application is built.

I’m not sure, probably not initially, but at a certain point I did do a fresh git clone+npm install. However, I don’t remember which npm version I used at that time. Tonight, I did do an rm -r node_modules + npm install after removing the app-module-path line