简体   繁体   English

nextjs - 使用 NODE_ENV=development 的下一个构建

[英]nextjs - next build with NODE_ENV=development

I'd like to build my nextjs project as development mode.我想将我的nextjs项目构建为开发模式。

and I tried like it我试过喜欢它

package.json包.json

{
  ...
  "scripts": {
    "dev": "next",
    "build:dev": "set NODE_ENV=development & next build",
    "build:prod": "set NODE_ENV=production & next build",
    "start:dev": "set NODE_ENV=development & next start",
    "start:prod": "set NODE_ENV=production & next start"
  }
  ...
}

next.config.js下一个.config.js

module.exports = withSass({
  env: {
    baseUrl: process.env.NODE_ENV === "development" ? "devServerURL": "prodServerURL"
  }
});

but I couldn't achieve what I want.但我无法实现我想要的。

so, I tried with some change.所以,我尝试了一些改变。

package.json包.json

  "scripts": {
    "dev": "next",
    "build": "next build",
    "start:dev": "set NODE_ENV=development & next start",
    "start:prod": "set NODE_ENV=production & next start"
  }

but it also doesn't work.但它也不起作用。

How can I build the next with development mode?如何使用开发模式构建next

Thanks in advance.提前致谢。

EDIT编辑

My OS is Windows 10.我的操作系统是 Windows 10。

See issue #9123, (Oct 18, 2019) :请参阅问题 #9123,(2019 年 10 月 18 日)

NODE_ENV is a reserved environment variable that cannot be changed. NODE_ENV 是不可更改的保留环境变量。 The only valid values are production, development, and test.唯一有效的值是生产、开发和测试。

If you need your app behavior to change in different production environments, please use a different variable like APP_ENV.如果您需要在不同的生产环境中改变您的应用行为,请使用不同的变量,如 APP_ENV。

And issues #17032 (Sep 12, 2020) :以及问题 #17032(2020 年 9 月 12 日)

process.env.NODE_ENV only has 2 possible values development and production . process.env.NODE_ENV只有 2 个可能的值developmentproduction If this is not set to that value you'll run into all kinds of library edge cases (especially in node_modules) where you get severely de-optimized results.如果未将其设置为该值,您将遇到各种库边缘情况(尤其是在 node_modules 中),在这些情况下您会得到严重的去优化结果。 Eg if you run a performance test you'll get significantly worse results if process.env.NODE_ENV is not set to production例如,如果您运行性能测试,如果process.env.NODE_ENV未设置为生产,您将获得更糟糕的结果

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

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