Could you please help me in understanding the below error:
js content:
const assert = require('assert').strict;
var res = assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
Error:
TypeError: Cannot read property 'deepEqual' of undefined
My understanding:
According to the Nodejs
doc, using .strict
while loading 'assert
' module will let us in restrictive mode which results in the behavior of assert.deepEqual()
and assert.deepStrictEqual()
to be same and as a result of this description. The output should be
"errors.AssertionError"
please guide me?
Make sure you are using node v. 9.10.1 v. 9.10.1 assert API since strict
functionality is not compatible with previous node versions. Here is node v. 8.11.1 and v. 8.11.1 assert API so as you can see strict
is not available.
In my case it works fine using node v. 9.10.1.
const assert = require('assert').strict;
// check your node version
console.log(process.version)
assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
v9.10.1
assert.js:49
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: Input A expected to deepStrictEqual input B:
+ expected - actual ... Lines skipped
[
[
...
2,
- 3
+ '3'
]
...
5
]