Netlify Error: Build script returned non-zero exit code: 254

Viewed 2553

Thank you for your help. I just have a simple html file that I wanted to host via netlify. I have three files in my git, index.html, style.css and the readme file.

The html file is just

<!DOCTYPE html>
    <head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">

    <link href="style.css" rel="stylesheet" type="text/css">
        <title>Company</title>
    </head>
    <body>
    <div>
         <h1> Coming Soon...</h1>
    </div>
    </body>
</html>

and the CSS file is:

h1  {
       text-align: center;
       font-size: 20pt;
       color: #000099;
       margin-bottom: 5px;
    }

The error I got is:

10:45:42 PM: Executing user command: npm run build
10:45:43 PM: npm
10:45:43 PM: ERR!
10:45:43 PM:  code
10:45:43 PM:  ENOENT
10:45:43 PM: npm ERR!
10:45:43 PM:  syscall open
10:45:43 PM: npm ERR! path /opt/build/repo/package.json
10:45:43 PM: npm
10:45:43 PM:  ERR!
10:45:43 PM:  errno
10:45:43 PM:  -2
10:45:43 PM: npm
10:45:43 PM:  ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'
10:45:43 PM: npm ERR! enoent
10:45:43 PM:  This is related to npm not being able to find a file.
10:45:43 PM: npm ERR! enoent
10:45:43 PM: npm ERR!
10:45:43 PM:  A complete log of this run can be found in:
10:45:43 PM: npm ERR!     /opt/buildhome/.npm/_logs/2019-10-23T02_45_43_136Z-debug.log
10:45:43 PM: Skipping functions preparation step: no functions directory set
10:45:43 PM: Caching artifacts
10:45:43 PM: Started saving pip cache
10:45:43 PM: Finished saving pip cache
10:45:43 PM: Started saving emacs cask dependencies
10:45:43 PM: Finished saving emacs cask dependencies
10:45:43 PM: Started saving maven dependencies
10:45:43 PM: Finished saving maven dependencies
10:45:43 PM: Started saving boot dependencies
10:45:43 PM: Finished saving boot dependencies
10:45:43 PM: Started saving go dependencies
10:45:43 PM: Finished saving go dependencies
10:45:46 PM: Error running command: Build script returned non-zero exit code: 254
10:45:46 PM: Failing build: Failed to build site
10:45:46 PM: failed during stage 'building site': Build script returned non-zero exit code: 254
10:45:46 PM: Finished processing build request in 13.711952891s
1 Answers

The relevant part is:

ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'
npm ERR! enoent
This is related to npm not being able to find a file.

Make sure to create a package.json first.
A npm init should take care of it.

Related