Installazione Bootstrap 4.1.0: in caso di errore!

Nel mondo dell’Open Source le cose non vanno mai come dovrebbero andare! E, anche l’apparentemente innocuo compito di installare i sorgenti e le dipendenze dell’oramai consolidato Bootstrap può riservare delle sorprese. Ho scaricato l’archivio ZIP dei sorgenti di Bootstrap dalla loro pagina di download ufficiale.

Dopo aver estratto l’archivio in una cartella di mio piacimento ho avviato l’installazione delle dipendenze come da istruzioni. E, come potete notare voi stessi, ho avuto qualche problemino.

$ npm install
events.js:183░░░░░░⸩ ⠹ extract:postcss-cli: sill extract bundlesize@0.16.0
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:553:10)
    at ReadEntry.entry.on (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
    at ReadEntry.[maybeEmitEnd] (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
    at ReadEntry.end (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
    at Unpack.[consumeBody] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
    at Unzip.(anonymous function).on.chunk (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
events.js:183░░░░░░⸩ ⠼ extract:yargs-parser: sill extract yargs-parser@4.2.1
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:553:10)
    at ReadEntry.entry.on (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
    at ReadEntry.[maybeEmitEnd] (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
    at ReadEntry.end (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
    at Unpack.[consumeBody] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
    at Unzip.(anonymous function).on.chunk (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
WARN tar ENOENT: no such file or directory, open '/Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/.staging/socket.io-client-c6efd21f/dist/socket.io.slim.js'
WARN tar ENOENT: no such file or directory, open '/Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/.staging/rollup-f2b9ab81/dist/rollup.es.js'
npm WARN bootstrap@4.1.0 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.

npm ERR! cancel after 1 retries!

Come dicevo, col software Open Source queste cose accadono di frequente. Il lavoro del programmatore è costituito, infatti, per almeno il 50% del suo tempo, dalla risoluzione di questo genere di problemi (che nulla hanno a che vedere con la programmazione vera e propria). Quindi, mi sono armato di santa pazienza (in esaurimento) e ho cercato di venirne a capo.

Come saprete (se già vi dilettate di queste cose) Node è un interprete JavaScript, dotato di API che ne estendono le capacità, che permette l’esecuzione di scripts JavaScript nell’ambiente di sistema. NPM è il Package Manager di Node ed è diventato ormai un software diffusissimo, uno standar de facto per lo sviluppo di software Web e non e la gestione di pacchetti e dipendenze.

Orbene! In seguito ad un’intuizione divina ho pensato che il problema della mia installazione fosse dovuto ai permessi di qualche cartella. Quindi sono andato a curiosare nel luogo in cui sono installati tutti i pacchetti di Node, ovvero nella directory /usr/local/lib/node_modules. Una volta li dentro ho verificato la configurazione dei permessi del contenuto.

$ ls -lG node_modules/
total 0
drwxr-xr-x   8 your_user_name  staff  272 12 Ott  2017 bower
drwxr-xr-x  14 your_user_name  staff  476  7 Nov 11:33 browserify
drwxr-xr-x  22 your_user_name  staff  748 26 Mar  2017 cordova
drwxr-xr-x   8 your_user_name  staff  272 26 Mar  2017 css-select
drwxr-xr-x   6 your_user_name  staff  204 26 Mar  2017 css-what
drwxr-xr-x  16 your_user_name  staff  544 26 Mar  2017 generator-wp-bones
drwxr-xr-x   9 your_user_name  staff  306 26 Mar  2017 graceful-fs
drwxr-xr-x   9 your_user_name  staff  306  7 Nov 13:46 grunt-cli
drwxr-xr-x   9 root            staff  306 12 Gen 18:54 js-beautify
drwxr-xr-x  11 your_user_name  staff  374 12 Ott  2017 jshint
drwxrwxr-x   7 your_user_name  staff  238 16 Feb  2017 json-beautifier
drwxr-xr-x  24 your_user_name  staff  816  7 Nov 15:28 less
drwxr-xr-x   6 root            staff  204 12 Gen 18:54 less-watch-compiler
drwxr-xr-x  14 your_user_name  staff  476 13 Nov 17:23 live-server
drwxr-xr-x   7 your_user_name  staff  238 12 Ott  2017 minimatch
drwxr-xr-x  27 root            staff  918  4 Apr 11:15 npm
drwxr-xr-x  11 your_user_name  staff  374 26 Mar  2017 npmconf
drwxr-xr-x  19 your_user_name  staff  646 12 Ott  2017 phonegap
drwxr-xr-x  12 your_user_name  staff  408 12 Ott  2017 pug
drwxr-xr-x  16 your_user_name  staff  544 16 Gen 19:14 uuid
drwxr-xr-x   6 your_user_name  staff  204 26 Mar  2017 yo

E difatti alcune cartelle sono proprietà dell’utente root. Il che potrebbe creare qualche disguido. Pertanto ho cambiato il proprietario di tutte le cartelle in questo modo.

$ sudo chown -R your_user_name node_modules

Dopo aver effettuato questa modifica ho riprovato a eseguire npm install e tutto è andato a buon fine, eccetto qualche messaggio di errore che si può ignorare (credo).

$ npm install
events.js:183░░░░░░⸩ ⠸ extract:minimist: sill extract minimist@1.2.0
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:553:10)
    at ReadEntry.entry.on (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
    at ReadEntry.[maybeEmitEnd] (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
    at ReadEntry.end (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
    at Unpack.[consumeBody] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
    at Unzip.(anonymous function).on.chunk (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)

> fsevents@1.1.3 install /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/fsevents
> node install

[fsevents] Success: "/Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> uws@9.14.0 install /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0


> iltorb@1.3.10 install /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/iltorb
> detect-libc prebuild-install || node-gyp rebuild

prebuild-install info begin Prebuild-install version 2.5.1
prebuild-install info looking for local prebuild @ prebuilds/iltorb-v1.3.10-node-v57-darwin-x64.tar.gz
prebuild-install info looking for cached prebuild @ /Users/your_user_name/.npm/_prebuilds/https-github.com-MayhemYDG-iltorb-releases-download-v1.3.10-iltorb-v1.3.10-node-v57-darwin-x64.tar.gz
prebuild-install http request GET https://github.com/MayhemYDG/iltorb/releases/download/v1.3.10/iltorb-v1.3.10-node-v57-darwin-x64.tar.gz
prebuild-install http 200 https://github.com/MayhemYDG/iltorb/releases/download/v1.3.10/iltorb-v1.3.10-node-v57-darwin-x64.tar.gz
prebuild-install info downloading to @ /Users/your_user_name/.npm/_prebuilds/https-github.com-MayhemYDG-iltorb-releases-download-v1.3.10-iltorb-v1.3.10-node-v57-darwin-x64.tar.gz.29945-29ba072d5c85f.tmp
prebuild-install info renaming to @ /Users/your_user_name/.npm/_prebuilds/https-github.com-MayhemYDG-iltorb-releases-download-v1.3.10-iltorb-v1.3.10-node-v57-darwin-x64.tar.gz
prebuild-install info unpacking @ /Users/your_user_name/.npm/_prebuilds/https-github.com-MayhemYDG-iltorb-releases-download-v1.3.10-iltorb-v1.3.10-node-v57-darwin-x64.tar.gz
prebuild-install info unpack resolved to /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/iltorb/build/bindings/iltorb.node
prebuild-install info unpack required /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/iltorb/build/bindings/iltorb.node successfully
prebuild-install info install Successfully installed prebuilt binary!

> node-sass@4.7.2 install /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.2/darwin-x64-57_binding.node
Download complete  ⸩ ⠋ :
Binary saved to /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Caching binary to /Users/your_user_name/.npm/node-sass/4.7.2/darwin-x64-57_binding.node

> node-sass@4.7.2 postinstall /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/node-sass
> node scripts/build.js

Binary found at /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Testing binary
Binary is fine

> nodemon@1.17.2 postinstall /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/nodemon
> node -e "console.log('\u001b[32mLove nodemon? You can now support the project via the open collective:\u001b[22m\u001b[39m\n > \u001b[96m\u001b[1mhttps://opencollective.com/nodemon/donate\u001b[0m\n')" || exit 0

Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate


> sinon@4.4.6 postinstall /Users/your_user_name/Sites/bootstrap_cv_15-04-2018/node_modules/sinon
> node -e "console.log('\u001b[32mLove sinon? You can now support the project via the open collective:\u001b[22m\u001b[39m\n > \u001b[96m\u001b[1mhttps://opencollective.com/sinon/donate\u001b[0m\n')" || exit 0

Love sinon? You can now support the project via the open collective:
 > https://opencollective.com/sinon/donate

npm WARN bootstrap@4.1.0 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.

added 1600 packages from 1445 contributors in 62.771s