Importing `natural` causes `dotenv` to load env variables & log confusing messages
Author: TimonLukasCreated Jun 17, 2026Updated Jun 17, 2026
LabelsBug
Describe the bug
When natural is installed and imported, 5 lines of spam are logged by dotenv:
// example.mjs
import natural from "natural"
console.log(natural.LevenshteinDistance("foo", "oof"))> node example.mjs
◇ injected env (0) from .env // tip: ⌘ suppress logs { quiet: true }
◇ injected env (0) from .env // tip: ⌘ custom filepath { path: '/custom/path/.env' }
◇ injected env (0) from .env // tip: ⌘ multiple files { path: ['.env.local', '.env'] }
◇ injected env (0) from .env // tip: ⌘ enable debugging { debug: true }
◇ injected env (0) from .env // tip: ⌘ override existing { override: true }
2The exact 5 messages change every time, but since there's no indication for the source, they feel concerning.
To Reproduce In an empty directory:
> npm init -y
> echo 'import natural from "natural"
console.log(natural.LevenshteinDistance("foo", "oof"))'>example.mjs
> node example.mjs
◇ injected env (0) from .env // tip: ◈ secrets for agents [www.dotenvx.com]
◇ injected env (0) from .env // tip: ◈ secrets for agents [www.dotenvx.com]
◇ injected env (0) from .env // tip: ◈ encrypted .env [www.dotenvx.com]
◇ injected env (0) from .env // tip: ⌘ custom filepath { path: '/custom/path/.env' }
◇ injected env (0) from .env // tip: ◈ secrets for agents [www.dotenvx.com]
2
I'm using node v24.16.0 and npm 11.13.0.
Expected behavior
- No ads (apparently
dotenvadded them a few months back) - Ideally importing the library shouldn't affect global state by loading environment variables from
.env
Screenshots
Desktop (please complete the following information):
- OS: Fedora
- Browser /
- Version:
node v24.16.0npm 11.13.0
Additional context
In a way, the ad spam is a blessing in disguise for me, since it showed me that importing natural has side effects. Importing from a nested path works without issues, since the files calling dotenv.config() aren't loaded. But the fact that it happens on a normal import is quite unexpected, and probably not intended?
Source: NaturalNode/natural