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).
meteor add ostrio:meteor-rootimport path from 'path';
const 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().
import path from 'path';
const 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.
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.
From the package directory:
npm install
npm testRuns 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- Thanks to @Konard for testing and maintaining Windows support.
- 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
