pawi
pawi

Reputation: 2523

Why is "~/" not recognized from node.js?

I wanted to set a path to my user folder with "~/". Why is this not valid in javascript?

Upvotes: 3

Views: 263

Answers (2)

cmbuckley
cmbuckley

Reputation: 42517

Tilde expansion is a bash feature that does not necessarily apply dependent on where the software is deployed. It also opens up questions about supporting other operators.

See https://github.com/nodejs/node/issues/684

Upvotes: 2

T.J. Crowder
T.J. Crowder

Reputation: 1075219

It has nothing to do with JavaScript. Node's file operations just don't expand ~ for you. It's not something that the file system automatically handles, it's something various programs (like your terminal, file manager, etc.) handle. You can get the home directory via os.homedir().

Upvotes: 8

Related Questions