nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

nuxt build is interactive and making it non-interactive is not obviously documented

Open mattpr opened this issue 3 years ago • 8 comments

This is a problem for CI builds.

Versions

$ node node_modules/nuxt/bin/nuxt.js build --version
@nuxt/cli v2.15.1
$ npx envinfo --binaries --system
npx: installed 1 in 1.435s

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
    Memory: 101.58 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.19.0 - ~/.nvm/versions/node/v12.19.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v12.19.0/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.19.0/bin/npm

Reproduction

Running...

$ yarn install --frozen-lockfile --non-interactive --prefer-offline --no-progress
$ NODE_ENV=production NUXT_ENV_API_URI="/api"  node node_modules/nuxt/bin/nuxt.js build --quiet

Results in interactive prompt...

ℹ NuxtJS collects completely anonymous data about usage.                                                                                                                                            15:49:45
  This will help us improve Nuxt developer experience over time.
  Read more on https://git.io/nuxt-telemetry

? Are you interested in participating? (Y/n)

I tried using --quiet hoping it would stop being interactive but it didn't make any difference...and on the CI I would rather that it is NOT quiet but that it is non-interactive.

nuxt build --help doesn't reveal any options to answer these interactive questions or force non-interactive mode.

$ node node_modules/nuxt/bin/nuxt.js build --help
  Usage: nuxt build <dir> [options]

  Compiles the application for production deployment

  Options:

    --spa, -s          Launch in SPA mode
    --universal, -u    Launch in Universal mode (default)
    --config-file, -c  Path to Nuxt config file (default: nuxt.config)
    --modern, -m       Build/Start app for modern browsers, e.g. server, client and false
    --target, -t       Build/start app for a different target, e.g. server, serverless and static
    --no-force-exit    Whether Nuxt should force exit after the command has finished
    --version, -v      Display the Nuxt version
    --help, -h         Display this message
    --no-processenv    Disable reading from process.env and updating it with dotenv
    --dotenv           Specify path to dotenv file (default: .env). Use false to disable
    --no-lock          Do not set a lock on the project when building
    --analyze, -a      Launch webpack-bundle-analyzer to optimize your bundles
    --devtools         Enable Vue devtools
    --no-generate      Don't generate static version for SPA mode (useful for nuxt start)
    --quiet, -q        Disable output except for errors
    --standalone       Bundle all server dependencies (useful for nuxt-start)

Steps to reproduce

Install nuxt, run build.

What is Expected?

nuxt should have documented options to give mandatory inputs and/or non-interactive switch. If non-interactive mode is set/implied by environment, then this should be documented.

It is desirable to be able to force non-interactive mode in an interactive environment (e.g. for testing CI script on development machines before pushing to CI).

What is actually happening?

nuxt build has interactive prompts.

mattpr avatar Mar 01 '21 15:03 mattpr

It looks like I can work around this specific interactive problem by adding this ENV to the build command: NUXT_TELEMETRY_DISABLED=1

But it would be nice in general if nuxt build had a way to NEVER prompt (e.g. --non-interactive). If required config is missing in non-interactive mode...then just error out with a message saying that.

mattpr avatar Mar 01 '21 15:03 mattpr

Thanks for your contribution to Nuxt! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

stale[bot] avatar Jul 08 '21 02:07 stale[bot]

This is still reproducible.

$ git clone https://github.com/nuxt/nuxt.js.git
$ cd nuxt.js
$ git rev-parse --short HEAD
8e725d34
$ yarn install --frozen-lockfile --non-interactive --prefer-offline --no-progresse node_modules/nuxt/bin/nuxt.js build --quiet
    # ...
$ NODE_ENV=production NUXT_ENV_API_URI="/api"  node node_modules/nuxt/bin/nuxt.js build --quiet

? Are you interested in participating? (Y/n)

mattpr avatar Jul 14 '21 16:07 mattpr

Up (same problem)

Gredys avatar Sep 10 '21 14:09 Gredys

Thanks for your contribution to Nuxt! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

stale[bot] avatar Apr 27 '22 18:04 stale[bot]

Still reproducible.

git clone https://github.com/nuxt/nuxt.js.git
cd nuxt.js/
git rev-parse --short HEAD
# 777a4b7f
yarn install --frozen-lockfile --non-interactive --prefer-offline --no-progress
# ...
NODE_ENV=production NUXT_ENV_API_URI="/api"  node node_modules/nuxt/bin/nuxt.js build --quiet
# 
# ? Are you interested in participating? (Y/n)
# 
NUXT_TELEMETRY_DISABLED=1 NODE_ENV=production NUXT_ENV_API_URI="/api"  node node_modules/nuxt/bin/nuxt.js build --quiet
# (no output or interactive prompt)

NUXT_TELEMETRY_DISABLED works as a workaround, should be documented. Would be nice if cli build command didn't default to interactive or had an obvious flag to turn it off. I haven't checked if the CLI options or ENV documentation has been updated since reporting.

mattpr avatar Apr 28 '22 08:04 mattpr

https://github.com/nuxt/telemetry/issues/30#issuecomment-1187729192

tol64 avatar Jul 18 '22 16:07 tol64

This should not be reproducible in CI. Locally it will prompt event with --quiet (as that's not the same thing as non-interactive) unless you are running a test or don't have a TTY available, but we do test for CI (these providers supported out of the box) and support setting CI variable as well to enable CI mode.

If you continue to experience this, would you provide some more info on your CI setup?

danielroe avatar Feb 14 '23 11:02 danielroe

This issue was closed because it was open for 7 days without a reproduction.

github-actions[bot] avatar Aug 09 '23 01:08 github-actions[bot]