【问题标题】:Netlify: No build command found, continuing to publishingNetlify:未找到构建命令,继续发布
【发布时间】:2020-12-08 18:14:15
【问题描述】:

我正在尝试使用 netlify 及其 lambda 函数功能来运行节点函数。基于https://css-tricks.com/using-netlify-forms-and-netlify-functions-to-build-an-email-sign-up-widget/

我无法让节点模块工作(请参阅ImportModuleError","errorMessage":"Error: Cannot find module while using Netlify lambda functions with dependencies

我刚刚意识到有一个部署日志,其中包含:

2:53:02 PM: Build ready to start
12:53:03 PM: build-image version: 8e31xxxxxxx
12:53:03 PM: build-image tag: v2.8.2
12:53:03 PM: buildbot version: 45cd000yyyyyyy
12:53:03 PM: Fetching cached dependencies
12:53:03 PM: Starting to download cache of 7.3MB
12:53:03 PM: Finished downloading cache in 291.717877ms
12:53:03 PM: Starting to extract cache
12:53:04 PM: Finished extracting cache in 85.783157ms
12:53:04 PM: Finished fetching cache in 381.732805ms
12:53:04 PM: Starting to prepare the repo for build
12:53:04 PM: Preparing Git Reference refs/heads/master
12:53:05 PM: Found netlify.toml. Overriding site configuration
12:53:05 PM: Different functions path detected, going to use the one specified in the toml file: './functions' versus '' in the site
12:53:05 PM: No build command found, continuing to publishing
12:53:05 PM: Starting to deploy site from '/'

我的 netlify.toml 只有以下内容:

[build]
  functions = "./functions"

我是否应该添加其他内容以允许使用节点依赖项?

编辑:

我的 package.json:

"name": "test2",
"version": "1.0.0",
"description": "",
"scripts": {
 "test": "echo \"Error: no test specified\" && exit 1",

 },
 "repository": {
 "type": "git",
 "url": "git+https://github.com/kc1/test2.git"
 },
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/kc1/test2/issues"
 } ,
"homepage": "https://github.com/kc1/test2#readme",
"dependencies": {
"dotenv": "^8.2.0",
"node-fetch": "^2.6.1"

} }

我意识到我没有构建脚本。你应该推荐什么?我尝试构建:'npm run build',但这导致构建失败..

https://app.netlify.com/sites/inspiring-ardinghelli-4a4da5/deploys/5fd02bbd61df720008e0a041

【问题讨论】:

    标签: javascript node.js netlify


    【解决方案1】:

    这是来自Express 的博客文章,但应该是相似的。

    netlify.toml 看起来像这样:

    [build]
      command = "npm install && npm run build"
      functions = "functions"
    

    https://www.netlify.com/blog/2018/09/13/how-to-run-express.js-apps-with-netlify-functions/

    https://github.com/neverendingqs/netlify-express/blob/master/netlify.toml

    确保您的 package.json 实际上有构建命令。

    https://stackoverflow.com/a/53311374/3850405

    【讨论】:

    • 如果您真的花时间阅读我为package.json 提供的链接,您会发现您的package.json 不包含构建命令。 npm run build: runs the build field from the package.json scripts field. stackoverflow.com/a/53311374/3850405 package.json 来自我链接到的 Github,例如:github.com/neverendingqs/netlify-express/blob/master/…
    • 我阅读了所有的链接。我来自 python 背景,对 package.json 和 node 中的构建过程不太了解。我意识到我的 package.json 不包含构建脚本,但我不明白其中的构建脚本使用什么。我尝试将 "build": "npm run build" 添加到 package.json 产生 app.netlify.com/sites/inspiring-ardinghelli-4a4da5/deploys/… 。你会在这里推荐什么?
    • npm run build 映射到 package.json -> scripts -> build。给定示例,他们有一个构建脚本可以执行"build": "netlify-lambda build express",。请查看这个完整的示例,并在继续之前了解其中的所有内容,这将是我最好的建议。 gist.github.com/skatkov/b524a6e60a5313acc4d299471a2a3902
    猜你喜欢
    • 2019-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多