loose-envify
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
js-tokens | 4.0.0 | 6.39 kB | MIT | prod |
Loose-envify is a fast and selective process.env
replacer that leverages js-tokens instead of an abstract syntax tree (AST). This npm package operates in a similar manner to envify, but delivers much faster performance.
To use loose-envify in your JavaScript project, you need to interact with its interface which matches that of envify, including the Command Line Interface (CLI). However, loose-envify does not handle broken syntax, it does not look within embedded expressions in template strings, and it does not replace oddly-spaced or oddly-commented expressions.
For instance, the following pieces of code do not work with loose-envify:
console.log(`the current environment is ${process.env.NODE_ENV}`);
console.log(process./*won't*/env./*work*/NODE_ENV);
But a correct usage would be:
console.log(process.env.NODE_ENV);
This correctly logs the current environment's NODE_ENV value, by replacing process.env.NODE_ENV
with its respective value.
The documentation for loose-envify is primarily present within the README file in the package’s GitHub repository. You can find comprehensive information on the usage, pitfalls and benchmarks of this npm package at https://github.com/zertosh/loose-envify.