设置节点。iisnode中的js环境变量(NODE_ENV)用于生产/开发/测试

时间:2021-07-30 23:23:12

How do we tell iisnode to run our Node.js application environment in production/development/test?

如何告诉iisnode运行我们的节点。生产/开发/测试中的js应用环境?

We have successfully gotten our Node.js app running with iisnode but process.env.NODE_ENV is coming out as 'undefined'.

我们已经成功地得到了我们的节点。js应用程序运行iisnode但process.env。NODE_ENV是“未定义的”。

At the moment, our web.config file is written this way:

现在,我们的网络。配置文件是这样写的:

<configuration>
  <system.webServer>

    <handlers>
      <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
    </handlers>

    <rewrite>
      <rules>
        <rule name="app">
          <match url="/*" />
          <action type="Rewrite" url="app.js" />
        </rule>
      </rules>
    </rewrite>

    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment="node_modules" />
        </hiddenSegments>
      </requestFiltering>
    </security>    

  </system.webServer>
  <appSettings>
    <add key="NODE_ENV" value="production" />
  </appSettings>
</configuration>

1 个解决方案

#1


13  

Joachim is right above that adding <iisnode node_env="production" /> to web.config allows control over the NODE_ENV value. Another way is to add the iisnode.yml file next to your web.config, and in there spcify the NODE_ENV value as node_env: production. See other settings you can use in iisnode.yml at https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml

Joachim在上面添加了 到web。配置允许控制NODE_ENV值。另一种方法是添加iisnode。在你的网络旁边的yml文件。配置,并在其中指定NODE_ENV值为NODE_ENV: production。参见可以在iisnode中使用的其他设置。yml:https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml

#1


13  

Joachim is right above that adding <iisnode node_env="production" /> to web.config allows control over the NODE_ENV value. Another way is to add the iisnode.yml file next to your web.config, and in there spcify the NODE_ENV value as node_env: production. See other settings you can use in iisnode.yml at https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml

Joachim在上面添加了 到web。配置允许控制NODE_ENV值。另一种方法是添加iisnode。在你的网络旁边的yml文件。配置,并在其中指定NODE_ENV值为NODE_ENV: production。参见可以在iisnode中使用的其他设置。yml:https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml