How to get the root path of the Vue project from the browser when running npm run serve
eg: the path E:myApp
Thanks in advance
I’v tried these:
process.cwd()
but got/
.require.resolve
but got webpack errorMODULE_NOT_FOUND
__dirname
andpath.resolve(__dirname)
return/
The Vue verison is ^3.2.37
and I use Vue CLI
.
2
Answers
It’s more a node problem, you can use:
You could always define a computed environment variable in your
vue.config.js
fileThen in your app you can reference the environment variable
Note that this value will be fixed and never change once you build your app.