My angular & node app structure is like this.
MyApp/
----app/
--------components/
-----------angular js files(js,css)
----server/
--------server.js
----index.html
And I want to use express.static()
to set static files such as angular.js files or css files. but, I'm not sure how to point to upper folder when using static(__dirname +'/app')
.
__dirname
means current directory but I want to point upper directory.
How about:
var path = require('path');
var dir = path.normalize(__dirname +'/../app');
from the documentation :
Normalize a string path, taking care of '..' and '.' parts.
When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.