dotenv: Getting error while reinstalling the dotenv (updating to `16.4.4` should fix. apologies for the bad patch release of `16.4.3` everyone)
Just got an error after running npm i and then npm start on my project. Strange thing is that this error started apearing after only when i deleted my package-lock.json and node modules folder then reinstalling them via npm i
` D:\projects\Winkget proj\Partner\server\node_modules\dotenv\lib\main.js:210 if (options?.encoding) { ^
SyntaxError: Invalid or unexpected token at Module._extensions…js (node:internal/modules/cjs/loader:1435:10)
Node.js v20.10.0
[nodemon] app crashed - waiting for file changes before starting…
`
the file where the error os occuring is located in node modules folder & error is =>
i have checked the same file from my old projects there is some changes that appeared after reinstalling the node modules
this is the old file ==>
this is my main js file where i have import dotenv package =>
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 1
- Comments: 28 (12 by maintainers)
Thanks @motdotla. We’ll test out removing the import and
config
call. Thanks for maintaining dotenv. 🎉Reiterating @utkarsh621x, we are on node v 20.10.0 when we got the error.
Sir i am already on node v20.10.0 but still facing the error
I successfully resolved the error by removing the caret (^) from the dotenv version specifier in the package.json file. It appears that there were compatibility issues with the latest version being installed by the caret, so I switched to version 16.0.0, which is functioning as expected.
Hi, getting the same error with latest 16.4.3 version. I am using Node.js version 12.16.3. It looks like the optional chaining operator (?.) is not supported in Node.js v12. Only starting from node v14 it is supported.
Your package.json does say this: “engines”: { “node”: “>=12” }, Seems to be in violation.