[英]Js - get string variable from env file
I have this value in my env file:我的 env 文件中有这个值:
REACT_APP_CHAIN_ID=56
and when I try to get the value of this variable in my file test.ts:当我尝试在我的文件 test.ts 中获取此变量的值时:
console.log("address : " + process.env.REACT_APP_CHAIN_ID);
I have undefined value?我有未定义的价值?
Try with using typescript instead.尝试使用 typescript 代替。 Rename all your .js files into .ts .将所有.js文件重命名为.ts 。 And use ts-node./index.ts
instead.并使用ts-node./index.ts
代替。
But before that do not forget to install instances: npm install -g typescript ts-node
or if you are using yarn: yarn add -DE typescript
or just yarn add -D typescript
then use npx tsc -init
or simply tsc -init
But before that do not forget to install instances: npm install -g typescript ts-node
or if you are using yarn: yarn add -DE typescript
or just yarn add -D typescript
then use npx npx tsc -init
or simply tsc -init
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.