简体   繁体   English

VSTS npm无法设置NODE_ENV

[英]VSTS npm unable to set NODE_ENV

I am unable to set NODE_ENV in VSO release management. 我无法在VSO版本管理中设置NODE_ENV。 In development the npm script runs fine. 在开发中,npm脚本运行良好。

"start:dev": "SET NODE_ENV=development&&gulp dev-serve"

But in VS Team Services release management when I run the npm task with the command I get an error that the command is unrecognized. 但是在VS Team Services版本管理中,当我使用命令运行npm任务时,出现错误,表明该命令无法识别。

"start:prod": "SET NODE_ENV=production&&gulp prod-serve"

How do I set NODE_ENV in production? 如何在生产中设置NODE_ENV?

I modified my build process a bit and in turn made me realize the issue. 我对构建过程进行了一些修改,从而使我意识到了这个问题。 I was using gulp to generate a config file and kick off my webpack process which needed the file. 我正在使用gulp生成配置文件,并启动了需要该文件的Webpack进程。 Mainly because I had started with gulp and hadn't yet figured out how to use webpack for config management. 主要是因为我从gulp开始,还没有弄清楚如何使用webpack进行配置管理。 I then found that using the gulp command as one of the npm commands was the issue. 然后,我发现使用gulp命令作为npm命令之一是个问题。 I replaced it with webpack and it runs fine. 我用webpack替换了它,并且运行良好。

This does not work 这行不通

"start": "SET NODE_ENV=production&&gulp serve" 

This works 这有效

"start": "SET NODE_ENV=production&&webpack -p"

I then found that there is a gulp task in VSTS. 然后,我发现VSTS中有一个吞噬任务。 So you need to use that to run a gulp task. 因此,您需要使用它来运行任务。 You can set env using a command prompt task and then run the gulp task. 您可以使用命令提示符任务设置env,然后运行gulp任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM