Problems with deploying plain HTML+CSS site

Hello guys,

I have a problem with deploying a plain HTML+CSS site to Netlify. I did an npm init so I have a package.json with no dependencies here, but still cannot deploy.

This is what I get:

4:53:50 AM:   1. Build command from Netlify app                             
4:53:50 AM: ────────────────────────────────────────────────────────────────
4:53:50 AM: ​
4:53:50 AM: $ CI= npm run build
4:53:50 AM: npm ERR! missing script: build
4:53:50 AM: npm ERR! A complete log of this run can be found in:
4:53:50 AM: npm ERR!     /opt/buildhome/.npm/_logs/2023-01-28T03_53_50_673Z-debug.log
4:53:50 AM: ​
4:53:50 AM:   "build.command" failed                                        
4:53:50 AM: ────────────────────────────────────────────────────────────────
4:53:50 AM: ​
4:53:50 AM:   Error message
4:53:50 AM:   Command failed with exit code 1: CI= npm run build (https://ntl.fyi/exit-code-1)
4:53:50 AM: ​
4:53:50 AM:   Error location
4:53:50 AM:   In Build command from Netlify app:
4:53:50 AM:   CI= npm run build
4:53:50 AM: ​
4:53:50 AM:   Resolved config
4:53:50 AM:   build:
4:53:50 AM:     command: CI= npm run build
4:53:50 AM:     commandOrigin: ui
4:53:50 AM:     publish: /opt/build/repo/build
4:53:50 AM:     publishOrigin: ui

Anyone knows whats wrong?

Kind regards,
A.N.

This is npm throwing an error that it can’t find a script called build in your package.json.

Your Netlify Build command is set to run an npm script called build:

If all you have done is create a package.json with npm init it probably contains only something like:

{
  "name": "temp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

If you wanted to run a script called build you would need to add one…

  "scripts": {
    "build": "... your custom build command would go here ...",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

In your case you probably just don’t want to have a Netlify Build command at all.

E.g. Don’t tell Netlify to run CI= npm run build.

Is there any way to set a different Netlify build command for each branch? (Or just completely remove it for some branches)

@Ahmed_Nakadi You can use File-base configuration, the netlify.toml file…

I dont understand it. So the solution is to put ```
[build.command] = ignore


in netlify.toml? I am kinda lost at this point.

@Ahmed_Nakadi That’s not what I was referring to.

I mean the info provided in the large code box here:

It demonstrates precisely what you asked, which is how you can specify different Netlify build commands for each branch.

What you then set per-branch would be up to you.

Since it sounds like you don’t need a build a command for certain branches you could try setting command = "" for those branches.