Deploy fails with "netlify build" command


Whenever I try to deploy my website on Netlify using the netlify build command, the build keeps failing:

7:38:08 PM: $ CI= npm run build
7:38:08 PM: > www@1.0.0 build
7:38:08 PM: > netlify build
7:38:10 PM:  ›   Error: Could not find the site ID. If your site is not on Netlify, please run `netlify init` or `netlify deploy` first. If it is, please run `netlify link`.




netlify build --offline


netlify link

to link the site first, and then run netlify build.

@hrishikesh even when deploying on Netlify? the --offline parameter times out, and the link doesn’t work.

Hi @andylemaire,

Sorry to see you’re still running into an issue.

Could you clarify what happens when you try netlify link?

Also did you try the commands from the error message:

Error: Could not find the site ID. If your site is not on Netlify, please run netlify initornetlify deployfirst. If it is, please runnetlify link.

Hey @Melvin on my local machine it works fine, but this is the log from the Netlify console:

8:36:14 PM: build.command from netlify.toml                               
8:36:14 PM: ────────────────────────────────────────────────────────────────
8:36:14 PM: ​
8:36:14 PM: $ CI= npm run build
8:36:14 PM: > www@1.0.0 build
8:36:14 PM: > netlify link && netlify build
8:36:17 PM: Logging into your Netlify account...
8:36:17 PM: Opening
8:36:17 PM: - Waiting for authorization...
8:41:17 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
8:41:17 PM:  ›   Error: Timed out waiting for authorization. If you do not have a Netlify account, please create one at, then run netlify login again.



Why would you run Netlify CLI in the Netlify CI platform? Simply run CI= npm run build as your build command. You have probably set up the wrong build command in your package.json.

@hrishikesh yes I did that now. Thanks.