Closed jnj16180340 closed 8 years ago
node-tmp uses the internal 'constants' module to define error codes, such as EBADF and ENOENT which should be caught during cleanup. In node 6, error codes have been removed from the 'constants' module.
EBADF
ENOENT
So, in node 6:
> process.binding('constants').EBADF undefined > process.binding('constants').ENOENT undefined > process.binding('constants').os.errno.EBADF 9 > process.binding('constants').os.errno.ENOENT 2
in node 4:
> process.binding('constants').EBADF 9 > process.binding('constants').ENOENT 2 > process.binding('constants').os undefined > process.binding('constants').os undefined
It seems that _c.ENOENT should be replaced by _c.os.errno.ENOENT etc. in node 6.
_c.ENOENT
_c.os.errno.ENOENT
And _c = require('constants') should be replaced by _c = process.binding('constants')... not really sure why the two aren't equal.
_c = require('constants')
_c = process.binding('constants')
Alternately, constants can be generated from require('os').constants.errno and require('fs').constants in node 6.
require('os').constants.errno
require('fs').constants
Although using process.binding isn't recommended (see https://github.com/nodejs/node/pull/2768 etc.), I'm using it for compatibility between node 4 and 6
process.binding
This seems related to my comment here. Even for older node.js releases I believe identifying the error by name instead of numeric code is more robust.
node-tmp uses the internal 'constants' module to define error codes, such as
EBADF
andENOENT
which should be caught during cleanup. In node 6, error codes have been removed from the 'constants' module.So, in node 6:
in node 4:
It seems that
_c.ENOENT
should be replaced by_c.os.errno.ENOENT
etc. in node 6.And
_c = require('constants')
should be replaced by_c = process.binding('constants')
... not really sure why the two aren't equal.Alternately, constants can be generated from
require('os').constants.errno
andrequire('fs').constants
in node 6.Although using
process.binding
isn't recommended (see https://github.com/nodejs/node/pull/2768 etc.), I'm using it for compatibility between node 4 and 6