Reputation: 2523
I wanted to set a path to my user folder with "~/". Why is this not valid in javascript?
Upvotes: 3
Views: 263
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
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