You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
npm test is failed on earlier Node.js versions #409
I've checked 'npm test' with earlier Node.js versions (v8.9.4) on linux env and
some tests such as bigint, callbackscope are required to higher version of Node.js.
Checking napi version is already in test/index.js but the value process.env.npm_config_NAPI_VERSION
is undefined on my setup, so.. users should set that value? (I have searched npm_config_NAPI_VERSION in the node and node-addon-api source but I couldn't find the define).
Or is it fine to modify that code in test/index.js by using a node version to pass tests?
I'm afraid this situation only happens in my environments (I have checked it on ubuntu laptops and servers) but the point is that process.env.npm_config_NAPI_VERSION is "undefined".
Even though there is code to splice test cases by using npm_config_NAPI_VERSION, I guess it's not working..
test/index.js
if ((process.env.npm_config_NAPI_VERSION !== undefined) &&
(process.env.npm_config_NAPI_VERSION < 50000)) {
// currently experimental only test if NAPI_VERSION
// is set to experimental. We can't use C max int
// as that is not supported as a number on earlier
// Node.js versions. Once bigint is in a release
// this should be guarded on the napi version
// in which bigint was added.
testModules.splice(testModules.indexOf('bigint'), 1);
testModules.splice(testModules.indexOf('typedarray-bigint'), 1);
}
As far as I understand, the bigint primitive type is added since Nodejs v10.4.0 so "npm test" is failed with earlier version on Nodejs.
Running test 'bigint'
/home/ryan/Desktop/node/node-addon-api/test/bigint.js:19
0n,
^
SyntaxError: Invalid or unexpected token
In addition, the version_management test is failed with Nodejs v8.4.0 because of napi in process.versions is Nan. I think this issue also can be solved if this code is working properly.
Hi @NickNaso,
I used to download Nodejs in https://nodejs.org/dist but now I can use nvm. :)
I've installed nvm, downloaded few versions of nodejs and tested. Still I get the same result.
I want better understand the problem:
Could you try this? nvm list
The output should be something like this:
Then if you have system you can switch to system version: nvm use system
Try to execute the test suite after this switch and if you don't have the problem is something correlated with nvm otherwise we need to investigate more deeply.
ryan@ryan-Inspiron-7566:~/Desktop/node/node-addon-api$ nvm list
-> v8.14.0
v11.4.0
system
default -> node (-> v11.4.0)
node -> stable (-> v11.4.0) (default)
stable -> 11.4 (-> v11.4.0) (default)
niojs -> N/A (default)
vlts/* -> lts/dubnium (-> N/A)
mlts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.15.1 (-> N/A)
lts/carbon -> v8.14.0
lts/dubnium -> v10.14.2 (-> N/A)
ryan@ryan-Inspiron-7566:~/Desktop/node/node-addon-api$ nvm use system
Now using system version of node: v8.12.0 (npm v6.4.1)
As you see system's verison is v8.12.0. With the latest clean node-addon-api code in master branch,
"npm test" is failed at the bigint test.
> node-addon-api@1.6.2 test /home/ryan/Desktop/node/node-addon-api
> node test
Starting test suite
Running test 'arraybuffer'
Running test 'asynccontext'
Running test 'asyncworker'
Running test 'basic_types/array'
Running test 'basic_types/boolean'
Running test 'basic_types/number'
Running test 'basic_types/value'
Running test 'bigint'
/home/ryan/Desktop/node/node-addon-api/test/bigint.js:19
0n,
^
SyntaxError: Invalid or unexpected token
I'm wondering when process.env.npm_config_NAPI_VERSION is set... or I can add code to check nodejs and napi version then skip those test cases with unproper nodejs.
Activity
[-]npm test is failed on earlier ode.js versions[/-][+]npm test is failed on earlier Node.js versions[/+]NickNaso commentedon Dec 17, 2018
Hi @nadongguri,
could you specify the Node.js versions that present the problem?
nadongguri commentedon Dec 17, 2018
Hi @NickNaso,
I'm afraid this situation only happens in my environments (I have checked it on ubuntu laptops and servers) but the point is that process.env.npm_config_NAPI_VERSION is "undefined".
Even though there is code to splice test cases by using npm_config_NAPI_VERSION, I guess it's not working..
As far as I understand, the bigint primitive type is added since Nodejs v10.4.0 so "npm test" is failed with earlier version on Nodejs.
In addition, the version_management test is failed with Nodejs v8.4.0 because of napi in process.versions is Nan. I think this issue also can be solved if this code is working properly.
NickNaso commentedon Dec 17, 2018
Are you using nvm?
nadongguri commentedon Dec 17, 2018
Hi @NickNaso,
I used to download Nodejs in https://nodejs.org/dist but now I can use nvm. :)
I've installed nvm, downloaded few versions of nodejs and tested. Still I get the same result.
NickNaso commentedon Dec 17, 2018
I want better understand the problem:

Could you try this?
nvm listThe output should be something like this:
Then if you have system you can switch to system version:
nvm use systemTry to execute the test suite after this switch and if you don't have the problem is something correlated with nvm otherwise we need to investigate more deeply.
nadongguri commentedon Dec 17, 2018
Hi @NickNaso,
As you see system's verison is v8.12.0. With the latest clean node-addon-api code in master branch,
"npm test" is failed at the bigint test.
I'm wondering when process.env.npm_config_NAPI_VERSION is set... or I can add code to check nodejs and napi version then skip those test cases with unproper nodejs.
nadongguri commentedon Dec 18, 2018
I knew how process.env_npm_config_#macro# is set by referring to #350.
mhdawson commentedon Dec 18, 2018
Out CI sets the NAPI_VERSION as follows
We should probably document this somewhere. I think I had tried to make it automatically default to the right value but was not successful.
mhdawson commentedon Dec 7, 2020
I recently added some additional detail in this section: https://github.com/nodejs/node-addon-api#tests. Closing. Please let us know if that was not the right thing to do.