Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信小程序使用环境变量报错(process.env) #15679

Open
proactivefly opened this issue May 8, 2024 · 1 comment
Open

微信小程序使用环境变量报错(process.env) #15679

proactivefly opened this issue May 8, 2024 · 1 comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@proactivefly
Copy link

相关平台

微信小程序

复现仓库

https://github.com/proactivefly/baitaner.git
小程序基础库: 3.3.0
使用框架: React

复现步骤

直接访问process.env报错 process is not defined 但是打印process is not defined.NODE_ENV

期望结果

期望能访问配置在.env中的变量

实际结果

报错process is not defined

环境信息

👽 Taro v3.6.22


  Taro CLI 3.6.22 environment info:
    System:
      OS: macOS 14.2
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
      npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.20 => 3.6.20 
      @tarojs/components: 3.6.20 => 3.6.20 
      @tarojs/helper: 3.6.20 => 3.6.20 
      @tarojs/mini-runner: 3.6.20 => 3.6.20 
      @tarojs/plugin-framework-vue3: 3.6.20 => 3.6.20 
      @tarojs/plugin-html: 3.6.20 => 3.6.20 
      @tarojs/plugin-platform-alipay: 3.6.20 => 3.6.20 
      @tarojs/plugin-platform-h5: 3.6.20 => 3.6.20 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels May 8, 2024
@cheerslvtao
Copy link

默认的环境变量文件前面少“.”, 改一下文件名就好了
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Status: Todo
Development

No branches or pull requests

2 participants