node.js(v6.2.2) error message on AIX(7.x)

Created on 26 Jul 2016  路  14Comments  路  Source: nodejs/node

  • Version: v6.2.2
  • Platform: AIX 1 7 00F9B5FB4C00
  • Subsystem:

ReferenceError: initLibraryFS is not defined

in main.js:

var fs = require('fs');                     // Basic File System API
eval(fs.readFileSync('./helpers_filesystem.js').toString());
function performGetInit()
{
    initLibraryFS();
}
setTimeout(performGetInit,2000);

in helpers_filesystem.js:

function initLibraryFS()
{
        ....
    console.log('initESLibraryFS is started!');
}

Any comments are appreciated!

question

All 14 comments

So I just tried this locally, albeit on OSX, and it worked fine. I unfortunately don't have an AIX box to test on. Have you tried upgrading to v6.3.1?

A quick question for you, is there a reason you are using eval fs.reafFileSync instead of require?

Original
Using Require / export

This issue tracker is for node core issues only. You may want to ask future userland questions over on the nodejs/help repo.

However, your code works just fine for me on Linux on v6.2.2.

Thank you both. Yes, code works just fine on LINUX, I tested it too. I am wondering why is not working on AIX.

/cc @mhdawson ?

@gireeshpunathil can you take a look at this issue,

ok, sure.

Ran a 100 times on AIX 6.1 with no reproduce. Hunting for a 7.1 system.

I ran the same test for @gireeshpunathil on AIX 7.1 - I don't see the issue there either after running 100 times.

Is the code you're running identical to that that you've pasted above? The reason I ask is the error is suggesting Node can't find initLibraryFS - if I misspell initLibraryFS then I get the same error as you.

Thank you all.

By looking at code again, there is one more thing I did not mention, I have variables declaration in helpers_filesystem. So it is like this(main.js is same):

in helpers_filesystem.js:

const DATATYPE = 'TEST';
const stringFileNames = '*.txt';
var mapDatatypeConfig = new Map();

function initLibraryFS()
{
....
mapDatatypeConfig.set(DATATYPE, stringFileNames);
console.log('initESLibraryFS is started!');
}

The above code works on LINUX, not on my AIX.
This morning I moved these variables declaration into main.js, then it works now, I just did some testing on AIX. So the difference is variable scope management?

Thank you!

Hmm - are you running node 6 on linux too? When I add the variables and
mapDatatypeConfig.set(DATATYPE, stringFileNames); to the helpers_filesystem on linux and AIX I also get the same error as you.

I tried the same code on node v4.4.0 and it works.

Thanks, gareth, it works on node 6 on LINUX:

$ uname -a
Linux flvr02 3.10.0-327.13.1.el7.x86_64 #1 SMP Thu Mar 31 16:04:38 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

I did a bit of investigation, as I can still reliably reproduce the error on both linux and AIX when we have the extra variables in.

I looked at the master branch, and it's visible there (for me at least). I tracked down the issue to when master upgraded to 4.9.385.18 - (from v8 - https://github.com/v8/v8/commit/1ecba0f ) This appears to be a change to do with scope however reading your code again - I think what's happening is that the variables are not accessible in the scope where the function is run.

Using @TheAlphaNerd 's example and adding the extra variables and calls in the function works for me on both AIX & Linux on node v6.

It's a bit of a mystery why node v6 works for you still, but I think the answer is that the correct / better way to do it is to use export & require

@hwandonggit any progress on your side ? It been a month and just wondering if we still need this open.

@mhdawson Thank you for follow up! Yes, After I moved these variables declaration into main.js, it works now on AIX. So we can close this thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

feross picture feross  路  208Comments

nicolo-ribaudo picture nicolo-ribaudo  路  147Comments

speakeasypuncture picture speakeasypuncture  路  152Comments

thecodingdude picture thecodingdude  路  158Comments

addaleax picture addaleax  路  146Comments