I'm using Zeit.Now and I was using publicRuntimeConfig in next.config.js just fine until I deployed, which yield Cannot use publicRuntimeConfig with target=serverless. The reasons is there but when I replace my publicRuntimeConfig with env, the process hangs indefinitely with the cryptic error at getBaseWebpackConfig (/Users/vadorequest/dev/TFP/node_modules/next/dist/build/webpack-config.js:91:95)
Replace publicRuntimeConfig with env in next.config.js and run now dev
Should build properly like https://github.com/zeit/next.js#build-time-configuration states.

Here is my next.config.js
require('dotenv').config({ path: '.env' });
console.debug(`Building Next with NODE_ENV="${process.env.NODE_ENV}"`);
module.exports = (phase, { defaultConfig }) => {
return {
env: { // See https://github.com/zeit/next.js#build-time-configuration
ORGANISATION_NAME: process.env.ORGANISATION_NAME,
NODE_ENV: process.env.NODE_ENV, // XXX Used in utils/env
GRAPHCMS_CACHE_ENDPOINT: process.env.GRAPHCMS_CACHE_ENDPOINT,
},
webpack: config => {
// Fixes npm packages that depend on `fs` module
config.node = {
fs: 'empty',
};
return config;
},
};
};
I got a more detailed stack trace by doing the following:
↵ 1  yarn dev
yarn run v1.17.3
$ next dev --port 8888
[ wait ] starting the development server ...
[ info ] waiting on http://localhost:8888 ...
Building Next with NODE_ENV="development"
Error: The key "NODE_ENV" under "env" in next.config.js is not allowed. https://err.sh/zeit/next.js/env-key-not-allowed
at webpackConfig.plugins._webpack.default.DefinePlugin.Object.keys.reduce (/Users/vadorequest/dev/TFP/node_modules/next/dist/build/webpack-config.js:91:161)
at Array.reduce (<anonymous>)
at getBaseWebpackConfig (/Users/vadorequest/dev/TFP/node_modules/next/dist/build/webpack-config.js:91:95)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Removing NODE_ENV: process.env.NODE_ENV from the file did fix the issue. Launching with the beta now dev command was hiding a self-explanatory error.
Thanks for reporting!
It's unfortunate that now dev didn't properly render the error and instead hid it away. As we speak, my team is working on a more refined version of the output, which simply relays exactly what your development tool is printing, without hiding lines away.
I'll let you know once it has launched!
@leo I guess we should close this? I don't know if the CLI was improved since then.
Yep! The error is now being surfaced. Thank you for reporting!
Most helpful comment
Yep! The error is now being surfaced. Thank you for reporting!