nextjs - 下一次构建 NODE_ENV=development
nextjs - next build with NODE_ENV=development
我想将我的 nextjs
项目构建为 开发 模式。
我试过喜欢
package.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
module.exports = withSass({
env: {
baseUrl: process.env.NODE_ENV === "development" ? "devServerURL": "prodServerURL"
}
});
但是我没有达到我想要的。
所以,我尝试了一些改变。
package.json
"scripts": {
"dev": "next",
"build": "next build",
"start:dev": "set NODE_ENV=development & next start",
"start:prod": "set NODE_ENV=production & next start"
}
但它也不起作用。
如何使用开发模式构建 next
?
提前致谢。
编辑
我的 OS 是 Windows 10.
参见issue #9123, (Oct 18, 2019):
NODE_ENV is a reserved environment variable that cannot be changed.
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.
和issues #17032 (Sep 12, 2020):
process.env.NODE_ENV
only has 2 possible values development
and
production
. 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. E.g. if you run a performance test
you'll get significantly worse results if process.env.NODE_ENV
is not
set to production
我想将我的 nextjs
项目构建为 开发 模式。
我试过喜欢
package.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
module.exports = withSass({
env: {
baseUrl: process.env.NODE_ENV === "development" ? "devServerURL": "prodServerURL"
}
});
但是我没有达到我想要的。
所以,我尝试了一些改变。
package.json
"scripts": {
"dev": "next",
"build": "next build",
"start:dev": "set NODE_ENV=development & next start",
"start:prod": "set NODE_ENV=production & next start"
}
但它也不起作用。
如何使用开发模式构建 next
?
提前致谢。
编辑
我的 OS 是 Windows 10.
参见issue #9123, (Oct 18, 2019):
NODE_ENV is a reserved environment variable that cannot be changed. 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.
和issues #17032 (Sep 12, 2020):
process.env.NODE_ENV
only has 2 possible valuesdevelopment
andproduction
. 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. E.g. if you run a performance test you'll get significantly worse results ifprocess.env.NODE_ENV
is not set to production