cli
cli copied to clipboard
deploy command does not succeed with `--json` flag
Describe the bug
I'm trying to deploy a legacy Vue Nuxt 2 SPA via CLI, but for some reason, I'm getting no errors at all why it's not successful. I tried to enable debug logs, but I can't see any detailed errors. It just hangs a bit after [get-build-settings.ts] getBuildSettings for baseDirectory: and exits.
DEBUG='*' netlify deploy --context deploy-preview --alias "deploy-preview-test" --build --json --site site-id --debug --auth auth_token --message "message" --skip-functions-cache
deploy:preAction start +0ms
deploy:init start +0ms
[project.ts]: detectFrameworks
[project.ts]: detectBuildSystem
[project.ts]: detectWorkspaces
[project.ts]: detectPackageManager
[project.ts]: detectFrameworksInPath - undefined
❯ Initial build environment
config: my-repo/netlify.toml
context: deploy-preview
cwd: my-repo
featureFlags: []
mode: cli
repositoryRoot: my-repo
siteId: site-id
❯ UI build settings
baseRelDir: true
build:
command: NODE_ENV=dev npm run build
publish: dist
❯ Resolved build environment
branch: my-branch
buildDir: my-repo
configPath: my-repo/netlify.toml
context: deploy-preview
env:
- my list of env vars...
❯
Resolved config
build:
command: NODE_ENV=dev npm run build
commandOrigin: ui
publish: my-repo/dist
publishOrigin: ui
headers:
- for: /*
values:
Access-Control-Allow-Origin: https://my-site.com
headersOrigin: config
plugins:
- inputs: {}
origin: config
package: /netlify/plugins/my-custom-plugin
redirects:
- from: /*
status: 200
to: /index.html
redirectsOrigin: config
netlify:init end +0ms
deploy:preAction end +0ms
[project.ts]: getBuildSettings
[project.ts]: detectFrameworks
[get-build-settings.ts] getBuildSettings for baseDirectory:
I'm trying to prepare a reproducible repository, but in the meantime, I'd like some input on how to proceed since I have no idea what the error could be. The deployment works if I do it on the web UI, but not via the CLI. We would like to switch to a CLI-based deployment flow via CLI and GitHub Actions. I have two of these legacy Nuxt 2 projects, and I can deploy the other successfully via the CLI, but not this one. The configuration is basically is the same. The other one doesn't have the netlify.toml file in the root, but if I delete that one, it will still not deploy.
Steps to reproduce
placeholder
Configuration
[[redirects]] from = "/*" to = "/index.html" status = 200
[[headers]] for = "/*" [headers.values] Access-Control-Allow-Origin = "https://mysite.com"
[[plugins]] package = "/netlify/plugins/my-plugin"
Environment
(nuxt2 with vue2)
System: OS: macOS 15.3.2 CPU: (8) arm64 Apple M1 Pro Memory: 264.89 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.12.1 - ~/.nvm/versions/node/v20.12.1/bin/node npm: 10.5.0 - ~/.nvm/versions/node/v20.12.1/bin/npm npmGlobalPackages: netlify-cli: 20.1.1
So, managed to figure it out. The culprit was the --json flag.
The nuxt build log is not in json format, and because of that, it fails silently without any errors.
The documentation says the following:
- json (boolean) - Output deployment data as JSON
It never says that my build output must be in json format, too.
So I think this is a bug, or at least should be mentioned somewhere.
Interesting, thanks for sharing @kristof-kasa. I'm not aware of such a bug, and you're right that this is not an expected behaviour. Can you share a minimal reproduction please? 🙏🏼
Hi everyone, I've been scratching my head over this issue for a while, and I finally traced the root cause down to a few changes introduced in netlify-cli@v21+ that weren’t obvious at first.
The situation we had was that our application is built in a separate CI/CD pipeline, and we only use the Netlify CLI to deploy the pre-built output. Our image is based on node@18-alpine, and we used npx to run the CLI — without pinning a specific version. Our original command looked something like this:
DEPLOY_JSON=$(npx netlify-cli deploy --alias=$DEPLOY_ALIAS --dir=$BUILD_DIR --json)
echo "($DEPLOY_JSON).deploy_url" | node -p > /tmp/deploy_url.txt
This had been working fine for a long time, but then it started failing silently when the netlify-cli version updated. (An effort to improve this behavior has been made in this PR. No errors were shown, and there was nothing actionable in the logs.
After a lot of debugging, I found that starting from [email protected], the deploy command builds by default. Since we have our own build pipeline in a separate workflow, this automatic build fails — but because we were also using --json, the CLI fails silently, with no stderr output or clear explanation. This made the issue 100x harder to debug.
We fixed this by doing three things:
- Pinning the CLI version with
npx [email protected], which is the latest version compatible withnode@18. - Adding the
--no-buildflag to disable the default build step. - Being extra cautious when using the
--jsonflag.
Adding the --debug flag doesn’t help much either — there aren’t any detailed error messages as described in this issue.
Hopefully this helps someone avoid the same trap we fell into. This was a tricky one!