Meteor.rootPath
Get the path to currently running instance of Meteor application on a server.
Features:
- 🤓 Compatibility with Windows, Linux, and MacOS environments;
- 👨💻 Globally available
Meteor.rootPath— absolute path toprograms/serverdirectory; - 👨💻 Globally available
Meteor.absolutePath— application root (path before.meteorinrootPath).

Installation
meteor add ostrio:meteor-root
Usage
1import path from 'path'; 2 3const pathToFile = path.join(Meteor.rootPath, 'directory', 'file.json');
Returns absolute path to programs/server directory of the running app, without trailing slash. Same as server process.cwd().
1import path from 'path'; 2 3const pathToFile = path.join(Meteor.absolutePath, 'private', 'file.json');
Returns application root when .meteor is present in rootPath (dev, meteor test-packages). In typical production bundles, equals Meteor.rootPath. See docs/paths-and-environments.md.
[!NOTE] Paths reflect where Meteor is running, not necessarily your git checkout. Test runners use temporary build directories.
TypeScript
Types ship via meteor-root.d.ts (module augmentation on meteor/meteor). The package uses zodern:types and package-types.json at publish time.
In your app, add zodern:types, configure tsconfig.json paths for meteor/* (see Meteor core types docs), then run meteor lint.
Testing
From the package directory:
npm install npm test
Runs runtime tests (mtest) and TypeScript declaration tests (tsd). mtest requires a Chromium/Chrome binary for Puppeteer.
npm run test:once # runtime only npm run test:types # declarations only # Custom port (runtime) npm run test:once -- --port 8888 # With local MongoDB (runtime) MONGO_URL="mongodb://127.0.0.1:27017/meteor-root-test" npm run test:once
Special thanks
- Thanks to @Konard for testing and maintaining Windows support.
Support this project:
- Star on GitHub
- Star on Atmosphere
- Sponsor maintainer via GitHub — support open source with one-time contribution or on a regular basis
- Sponsor veliovgroup via GitHub — support company behind this package
- Support via PayPal — support our open source contributions
- Use ostr.io — Monitoring, Analytics, WebSec, Web-CRON and Pre-rendering for a website