Wednesday, July 17, 2024

We are worried about Sharif. He left his home on June 28 to visit a friend, but since then he has vanished, his mobile phone is not reachable. His sister and his wife filed a missing person report at the police. I still hope that he had just a psycholigical crisis or problems with his wife (they married only 1 year ago) and doesn’t dare to speak about it. That would be a strange behaviour, but I’d prefer such an explanation over hearing that they found his motorcycle and his body somewhere in the jungle.

We are in the third week without Sharif, I start to imagine the worst case: that I must learn how to build the React front end. Until now I had successfully avoided the dirty details of Node, npm, React and webpack because Sharif was better than me with this part of Lino development.

Even when we assume that Sharif will soon come back, it’s a good thing that I am forced to do his job for some time. I started to read and review Introduction to npm, npx, NodeJS and React.

Of course my npm environment needs a upgrade:

$ npm -v
8.5.1
$ node -v
v12.22.9

$ sudo npm install -g n
[sudo] password for luc:

added 1 package, and audited 2 packages in 560ms

found 0 vulnerabilities

$ sudo n stable
  installing : node-v20.15.1
       mkdir : /usr/local/n/versions/node/20.15.1
       fetch : https://nodejs.org/dist/v20.15.1/node-v20.15.1-linux-x64.tar.xz
     copying : node/20.15.1
   installed : v20.15.1 (with npm 10.7.0)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
If "node --version" shows the old version then start a new shell, or reset the location hash with:
hash -r  (for bash, zsh, ash, dash, and ksh)
rehash   (for csh and tcsh)

$ npm -v
10.7.0
$ node -v
v20.15.1

I also did the following (don’t ask me why):

$ sudo npm upgrade -g react

Let’s try:

$ npm run build

> lino_react@24.5.0 build
> NODE_OPTIONS='--max-old-space-size=8192' webpack --mode production

[webpack-cli] Failed to load '/home/luc/work/react/webpack.config.js' config
[webpack-cli] Error: Cannot find module 'html-webpack-plugin'
Require stack:
- /home/luc/work/react/webpack.config.js
- /home/luc/work/react/node_modules/webpack-cli/lib/webpack-cli.js
- /home/luc/work/react/node_modules/webpack-cli/lib/bootstrap.js
- /home/luc/work/react/node_modules/webpack-cli/bin/cli.js
- /home/luc/work/react/node_modules/webpack/bin/webpack.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (/home/luc/work/react/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/luc/work/react/webpack.config.js:2:27)
    at Module._compile (/home/luc/work/react/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/luc/work/react/webpack.config.js',
    '/home/luc/work/react/node_modules/webpack-cli/lib/webpack-cli.js',
    '/home/luc/work/react/node_modules/webpack-cli/lib/bootstrap.js',
    '/home/luc/work/react/node_modules/webpack-cli/bin/cli.js',
    '/home/luc/work/react/node_modules/webpack/bin/webpack.js'
  ]
}

The message “Cannot find module ‘html-webpack-plugin’” makes me try the following:

$ sudo npm install -g html-webpack-plugin

added 44 packages in 2s

10 packages are looking for funding
  run `npm fund` for details

I am not sure about whether the difference between “sudo npm install -g” and “npm install” is important.

This story continues on Saturday, July 20, 2024.