Javascript ReferenceError:未定义进程

Javascript ReferenceError:未定义进程,javascript,process,environment-variables,Javascript,Process,Environment Variables,我正在运行一个k6测试,并对一些代码使用env变量。但我一直在犯这个该死的错误: ReferenceError:未定义进程 我曾尝试使用一些人在类似问题中建议的替代方法,使用_ENV.yadda,但没有效果 import http from "k6/http"; let formData = { client_id: "LoadTesting", grant_type: "blah_blah", scope: "Scope", }; const messageHeaders = {

我正在运行一个k6测试,并对一些代码使用env变量。但我一直在犯这个该死的错误:

ReferenceError:未定义进程

我曾尝试使用一些人在类似问题中建议的替代方法,使用_ENV.yadda,但没有效果

import http from "k6/http";

let formData = {
  client_id: "LoadTesting",
  grant_type: "blah_blah",
  scope: "Scope",
};
const messageHeaders = {
  'Content-Type': 'Client Type',
};

let user = null;
export function authorizeUser() {
  formData.client_secret = process.env.REACT_APP_CLIENT_SECRET;
  if (!user) {
    let res = http.post(`https://localhost:44341/connect/token`, formData, { headers: messageHeaders });
    if (res.status != 200) {
      console.log('res: ', res.status);
      throw new Error("couldn't load user");
    }
    user = JSON.parse(res.body).access_token;
    return user;
  }
}

我只想让我的环境变量工作

k6中的环境变量与Node.js中的环境变量的工作方式不同。请尝试以下内容:

k6中的环境变量与Node中的环境变量的工作方式不同。请尝试以下操作: