goodolddays
goodolddays

Reputation: 2683

nodejs: fs.access is undefined

I am using nodejs/express to develop a simple RESTful API. Yesterday I could make calls to the fs.access method (used to check the existence of a file/folder). I can't today. Even if I use the REPL on the terminal it says fs.access is undefined. This is the output:

> var fs = require('fs');
undefined
> fs.access
undefined
> fs.exists
[Function]

nodejs --version gives me this version, which is the latest available from Ubuntu's repositories: v0.10.25

I know there is the fs.exists method, but as per documentation it has been deprecated.

How can I solve?

Thank you,
Umar

Upvotes: 1

Views: 1180

Answers (1)

eaxix
eaxix

Reputation: 78

Node.js version 0.10.25 is not the latest and according to it's documentation a function named access is indeed not present in the file system api.

According to the official website, the latest LTS version is 4.2.6 and the latest stable one is 5.5.0. I've just checked and everything works as excepted on my computer using a recent version of Node.js.

If you're having trouble installing a more recent version of Node through your distribution's channels, you might want to consider using a third party package manager like Linuxbrew that installs stuff into your home directory, independent of the OS you're using.

Upvotes: 1

Related Questions