Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: encryptFile(...).then(...).catch(...).finally is not a function #7

Closed
anto-christo opened this issue Apr 30, 2019 · 5 comments

Comments

@anto-christo
Copy link
Contributor

Hi,
I was trying to run the CLI. However, I am not able to encrypt any file and always get the following error no matter which file. (I tried to run on both Windows 10 and Ubuntu 18)

warshield-error

As per my knowledge, these files are not read-only and the user does have access to them.
What may be the possible reasons for this error?
Any help in this regard is appreciated. Thank you.

@quantumsheep
Copy link
Owner

Hi,
Use -v or --verbose option to see exactly what goes wrong with your files.

@anto-christo
Copy link
Contributor Author

anto-christo commented May 2, 2019

Hi,
Adding the -v flag said it failed to add the file, i.e the file was not found. Running the command again with the file extension removed this error. Earlier I was just typing the file name without the extension.

However, the following new error has popped out.

E:\Code\warshield\warshield.js:280
        .finally(() => em.emit('end'));
                ^

TypeError: encryptFile(...).then(...).catch(...).finally is not a function
    at fs.stat (E:\Code\warshield\warshield.js:280:17)
    at FSReqWrap.oncomplete (fs.js:153:5)

Below is the part of code throwing the error.

encryptFile(file, key, tmp)
        .then(() => em.emit('done', file))
        .catch(() => em.emit('failed', file))
        .finally(() => em.emit('end'));

I searched online and found out that support for .finally may not be there in certain versions of Node.js. I think this maybe the issue here as well. Your thoughts on this? and May I know what version of Node.js are you using?

Just for the sake of running it, I modified the above code to as below and it worked perfectly fine.

encryptFile(file, key, tmp)
        .then(() => {
          em.emit('done', file)
          em.emit('end')
        })
        .catch(() => {
          em.emit('failed', file)
          em.emit('end')
        })

@quantumsheep
Copy link
Owner

quantumsheep commented May 2, 2019

It seems that your NodeJS version is outdated, my bad for not telling the minimum version required. I'm currently using NodeJS 10.15 since it's the LTS (and .finally() seems to be present from v10.x).

@anto-christo anto-christo changed the title Failed: (read-only or access denied files) TypeError: encryptFile(...).then(...).catch(...).finally is not a function May 3, 2019
@anto-christo
Copy link
Contributor Author

Upgrading Node.js to v10.x resolved the issue. Thank you.

@quantumsheep
Copy link
Owner

quantumsheep commented May 3, 2019

Precised in commit bc70546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants