readium/readium-js-viewer

NodeJS v5 upgrade (from v4)

danielweck opened this issue · 11 comments

Not an issue with Readium per-se, but some notes about the transition from NodeJS v4 to v5

https://nodejs.org

  • v4 LTS Long Term Support (mature and dependable)
  • v5 Stable (latest features)

On my Windows 10 machine, I used the MSI installer to setup v4 (I'd rather avoid upgrading to v5 for now).
On my OSX machine, I used the package installer to setup v4, but I wanted to upgrade to v5. Simply installing the v5 package over v4 did not work (failure to execute even the simplest NPM build command). So, I did the following and it all worked fine thereafter:

  • sudo rm -rf /usr/local/lib/node_modules
  • install NodeJS v5 OSX package
  • cd readium-js-viewer + rm -r node_modules
  • cd readium-js + rm -r node_modules
  • cd readium-shared-js + rm -r node_modules
  • cd readium-cfi-js + rm -r node_modules
  • navigate back inside readium-js-viewer top-level folder, and invoke npm run prepare
  • npm run dist+sourcemap

Success.

Mhmm, I had to invoke npm run prepare twice in order for npm run http to succeed (the opener Node module was missing in the node_modules folder). I then realized that invoking plain npm run install did not install zip-js in readium-js, in fact it removed it! Subsequently running npm run update would fix that, but sometimes running the NPM update command several times in a row would mess-up the node_modules folder again!! I know that dependency management has changed in NodeJS v5 (new algorithm that attempts to avoid deep nesting of redundant shared dependencies). So perhaps this is the cause of the problem (this does not fill me with confidence regarding v5 though!). The package.json dependencies seem pretty innocuous:
https://github.com/readium/readium-js/blob/develop/package.json#L46

  "dependencies": {
    "parallelshell": "latest",
    "opener": "latest",
    "http-server": "danielweck/http-server"
  },
  "devDependencies": {
    "crypto-js": "latest",
    "zipjs": "danielweck/zip.js",
    "requirejs-text": "latest",
    "gift": "latest"
  },

Any idea?

NPM v3 (which Node 5 ships with) is "BETA SOFTWARE" (quote):
https://github.com/npm/npm/releases/tag/v3.0.0

Time for an update on this. NodeJS is now at 6.9.1 / 7.2.0
https://nodejs.org

I'm still at 4.5.0 on my machine (NPM 2.15.9), and I am still able to compile ReadiumJS. I am concerned that NPM 3+ is now the default option, and this would probably break a few things (notably: relative paths into the node_module folders).

Checking now...
(I'm currently on Windows 10 using GitBash CLI, and NodeJS/NPM all 64-bit variants)

So far, so good: readium-cfi-js compiles fine with npm run prepare && npm run build (note: make sure to remove previous NPM v2 dependency tree rm -r node_modules).

Update: readium-shared-js compiles fine too (once again with npm run prepare && npm run build after deleting the NPM v2 node_modules folder).

Update: readium-js compiles fine too.

Note that the TravisCI builds are currently done with NodeJS 4.x (NPM 2.x), see:
https://travis-ci.org/readium/readium-js-viewer/builds/178232943

Time to update?
https://github.com/readium/readium-js-viewer/blob/develop/.travis.yml#L6

node_js:
- '4.2'

See available versions:
https://docs.travis-ci.com/user/languages/javascript-with-nodejs

Update: readium-js-viewer builds fine (npm run dist+sourcemap).

I am now going to update the TravisCI NodeJS version to "6" (see above comment):
https://travis-ci.org/readium/readium-js-viewer/builds/178243295

My final test with NodeJS 6+ / NPM 3+ is to invoke npm run prepare from readium-js-viewer a few more times. In the past (using NPM v5), this caused issues. All seems to work fine now though. Good news.

The TravisCI build failed (node v6.9.1 + npm v3.10.8):
https://travis-ci.org/readium/readium-js-viewer/builds/178243295
...investigating.

Update: the build actually produced a valid deployment of the cloud reader at Firebase and Surge
https://readium.firebaseapp.com
https://readium.surge.sh
...but the CFI unit tests failed to launch, resulting in failure to update the release:
https://github.com/readium/readium-js-viewer/releases/tag/0.25.0-alpha
Investigating...

TravisCI update: https://travis-ci.org/readium/readium-js-viewer/builds/178248747
Jasmine-Core NPM dependency now added to readium-cfi-js's package.json, should fix the build failure...