Breaking change after version 2.0.1 with Node v0.6
briemens opened this issue · 6 comments
Recently I'm getting Travis built errors on an existing node module testing on Node v0.6.19.
This module is using Watchr, which is using type checker ~2.0.1 as a dependency.
It seems you introduced a breaking change somewhere after 2.0.1, but only marked it as a patch (by only updating the last number of the version.)
I recommend going back and change the version to 2.1.x and rollback the breaking change after 2.0.1.
> typechecker@2.0.6 preinstall /home/briemens/Development/Crafity/modules/crafity-filesystem/node_modules/watchr/node_modules/typechecker
> node ./cyclic.js
/home/briemens/Development/Crafity/modules/crafity-filesystem/node_modules/watchr/node_modules/typechecker/cyclic.js:1
'fs').existsSync
^
TypeError: Object #<Object> has no method 'existsSync'
at Object.<anonymous> (/home/briemens/Development/Crafity/modules/crafity-filesystem/node_modules/watchr/node_modules/typechecker/cyclic.js:1:82)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
npm ERR! typechecker@2.0.6 preinstall: `node ./cyclic.js`
npm ERR! `sh "-c" "node ./cyclic.js"` failed with 1
npm ERR!
npm ERR! Failed at the typechecker@2.0.6 preinstall script.
npm ERR! This is most likely a problem with the typechecker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./cyclic.js
npm ERR! You can get their info via:
npm ERR! npm owner ls typechecker
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 3.8.0-27-generic
npm ERR! command "node" "/home/briemens/.nvm/v0.6.19/bin/npm" "install" "typechecker@2.0"
npm ERR! cwd /home/briemens/Development/Crafity/modules/crafity-filesystem/node_modules/watchr
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.24
npm ERR! code ELIFECYCLE
npm ERR! message typechecker@2.0.6 preinstall: `node ./cyclic.js`
npm ERR! message `sh "-c" "node ./cyclic.js"` failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/briemens/Development/Crafity/modules/crafity-filesystem/node_modules/watchr/npm-debug.log
npm not ok
npm not ok
Cheers!
The problem is with cyclic.js and the existsSync function on line 1. Which is not available before node v0.8 (was path.existsSync)
The Watchr library is depending on "typechecker": "~2.0.1", which is now broken on node v0.6.
The change to fs.existsSync is breaking other dependencies at the moment.
Here is a solution for making cyclic.js work again with older versions of node.
try {
if (require('fs').lstatSync('.git')) {
require('child_process').spawn(
'npm',
['install', '--force', require('./package.json').name],
{env: process.env, cwd: process.cwd(), stdio: 'inherit'}
);
}
} catch (err) {
return err;
}
So the problem can be solved by using lstatSync with a try/catch around it. Easy!
I tried path.existsSync
as well, but node > 0.6 prints the following warning. (not recommend)
path.existsSync is now called `fs.existsSync`.
Any chance you can fix this minor compatibility issue? Thanks!
+1. Facing the same issue. Would be good to get this compatibility fixed.
What is the purpose of this file cyclic.js, and why has it found its way into so many projects?
@amb26 if project A has a development dependency called project B that has a dependency of project A, then that creates a cyclic dependency, which npm will error about, cyclic.js fixes that error.
I'm unsure if newer versions of npm still have this issue.
cyclic.js
is maintained by the bevry/base project, https://github.com/bevry/base/blob/master/cyclic.js
TypeChecker will be updated in coming months when it is converted along with our over projects to ES6, and will get this update - details. As it seems this update is only for Node 0.6 from 2013, I don't think this of any urgency.
Removed cyclic.js
in v2.1.0, seems npm now handles cyclic dependencies correctly.