【问题标题】:Netlify Error: Build script returned non-zero exit code: 254Netlify 错误:构建脚本返回非零退出代码:254
【发布时间】:2020-02-19 05:25:29
【问题描述】:

感谢您的帮助。我只有一个简单的 html 文件,我想通过 netlify 托管它。我的 git 中有三个文件,index.html、style.css 和自述文件。

html文件只是

<!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>

CSS 文件是:

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

我得到的错误是:

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

【问题讨论】:

    标签: html github npm package.json netlify


    【解决方案1】:

    相关部分是:

    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.
    

    确保create a package.json first
    npm init 应该会处理它。

    【讨论】:

    • 谢谢!我尝试创建一个 package.json 文件,但它给了我新的错误。查看我的代码,您认为我的 package.json 中有什么内容。我没有使用任何我认为的包,所以我不知道包含我的包名称的“名称”部分中的内容。
    • @aztec242 你是如何创建你的package.json 的?与npm init?
    • EDIT::: 我意识到您的 package.json 需要指定存储库类型和 url
    猜你喜欢
    • 2022-06-13
    • 2020-06-19
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多