Javascript 盖茨比变形金刚夏普创造方案数字化海洋建造
你好。我在向digitalocean部署gatsby应用程序时遇到问题 我收到以下错误:Javascript 盖茨比变形金刚夏普创造方案数字化海洋建造,javascript,deployment,gatsby,digital-ocean,Javascript,Deployment,Gatsby,Digital Ocean,你好。我在向digitalocean部署gatsby应用程序时遇到问题 我收到以下错误: ERROR #11321 PLUGIN [2021-05-04T15:49:08.123576271Z] [2021-05-04T15:49:08.123581789Z] "gatsby-transformer-sharp" threw an error while running the [2021-05-04T15:49:08.123588327Z] createSchemaCu
ERROR #11321 PLUGIN
[2021-05-04T15:49:08.123576271Z]
[2021-05-04T15:49:08.123581789Z] "gatsby-transformer-sharp" threw an error while running the
[2021-05-04T15:49:08.123588327Z] createSchemaCustomization lifecycle:
[2021-05-04T15:49:08.123592428Z]
[2021-05-04T15:49:08.123597195Z] Expected undefined to be a GraphQL nullable type.
[2021-05-04T15:49:08.123602440Z]
[2021-05-04T15:49:08.217730653Z]
[2021-05-04T15:49:08.217738299Z] Error: Expected undefined to be a GraphQL nullable type.
[2021-05-04T15:49:08.217744559Z]
[2021-05-04T15:49:08.217748772Z] - customize-schema.js:485 imageNodeType
[2021-05-04T15:49:08.217755236Z] [workspace]/[gatsby-transformer-sharp]/customize-schema.js:485:11
[2021-05-04T15:49:08.217762490Z]
[2021-05-04T15:49:08.217767037Z] - customize-schema.js:644 createFields
[2021-05-04T15:49:08.217773273Z] [workspace]/[gatsby-transformer-sharp]/customize-schema.js:644:21
[2021-05-04T15:49:08.217777358Z]
[2021-05-04T15:49:08.217787660Z] - customize-schema.js:840 Object.module.exports [as createSchemaCustomization]
[2021-05-04T15:49:08.217794900Z] [workspace]/[gatsby-transformer-sharp]/customize-schema.js:840:13
[2021-05-04T15:49:08.217800428Z]
[2021-05-04T15:49:08.217804562Z] - api-runner-node.js:434 runAPI
[2021-05-04T15:49:08.217809280Z] [workspace]/[gatsby]/src/utils/api-runner-node.js:434:22
[2021-05-04T15:49:08.217815532Z]
[2021-05-04T15:49:08.217820057Z] - api-runner-node.js:585 Promise.catch.decorateEvent.pluginName
[2021-05-04T15:49:08.217839308Z] [workspace]/[gatsby]/src/utils/api-runner-node.js:585:13
[2021-05-04T15:49:08.217843813Z]
[2021-05-04T15:49:08.217847462Z] - debuggability.js:384 Promise._execute
[2021-05-04T15:49:08.217852580Z] [workspace]/[bluebird]/js/release/debuggability.js:384:9
[2021-05-04T15:49:08.217856512Z]
[2021-05-04T15:49:08.217860339Z] - promise.js:518 Promise._resolveFromExecutor
[2021-05-04T15:49:08.217864704Z] [workspace]/[bluebird]/js/release/promise.js:518:18
[2021-05-04T15:49:08.217868697Z]
[2021-05-04T15:49:08.217872694Z] - promise.js:103 new Promise
[2021-05-04T15:49:08.217876610Z] [workspace]/[bluebird]/js/release/promise.js:103:10
[2021-05-04T15:49:08.217880177Z]
[2021-05-04T15:49:08.217883861Z] - api-runner-node.js:583
[2021-05-04T15:49:08.217887975Z] [workspace]/[gatsby]/src/utils/api-runner-node.js:583:16
[2021-05-04T15:49:08.217892211Z]
[2021-05-04T15:49:08.217896077Z] - util.js:16 tryCatcher
[2021-05-04T15:49:08.217899976Z] [workspace]/[bluebird]/js/release/util.js:16:23
[2021-05-04T15:49:08.217905006Z]
[2021-05-04T15:49:08.217909323Z] - reduce.js:166 Object.gotValue
[2021-05-04T15:49:08.217913111Z] [workspace]/[bluebird]/js/release/reduce.js:166:18
[2021-05-04T15:49:08.217917332Z]
[2021-05-04T15:49:08.217921320Z] - reduce.js:155 Object.gotAccum
[2021-05-04T15:49:08.217925787Z] [workspace]/[bluebird]/js/release/reduce.js:155:25
[2021-05-04T15:49:08.217929725Z]
[2021-05-04T15:49:08.217933984Z] - util.js:16 Object.tryCatcher
[2021-05-04T15:49:08.217938317Z] [workspace]/[bluebird]/js/release/util.js:16:23
[2021-05-04T15:49:08.217942371Z]
[2021-05-04T15:49:08.217946448Z] - promise.js:547 Promise._settlePromiseFromHandler
[2021-05-04T15:49:08.217951069Z] [workspace]/[bluebird]/js/release/promise.js:547:31
[2021-05-04T15:49:08.217954599Z]
[2021-05-04T15:49:08.217958163Z]
not finished createSchemaCustomization - 0.226s
[2021-05-04T15:49:08.222876144Z]
[2021-05-04T15:49:08.479376150Z] npm ERR! code ELIFECYCLE
[2021-05-04T15:49:08.480113743Z] npm ERR! errno 1
[2021-05-04T15:49:08.487270336Z] npm ERR! gatsby-starter-default@0.1.0 build: `gatsby build`
[2021-05-04T15:49:08.487288402Z] npm ERR! Exit status 1
[2021-05-04T15:49:08.487293527Z] npm ERR!
[2021-05-04T15:49:08.487661112Z] npm ERR! Failed at the gatsby-starter-default@0.1.0 build script.
[2021-05-04T15:49:08.487672333Z] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[2021-05-04T15:49:08.500625147Z]
[2021-05-04T15:49:08.500829047Z] npm ERR! A complete log of this run can be found in:
[2021-05-04T15:49:08.501066886Z] npm ERR! /home/apps/.npm/_logs/2021-05-04T15_49_08_487Z-debug.log
[2021-05-04T15:49:08.527093479Z] building: exit status 1
[2021-05-04T15:49:08.533964962Z] ERROR: failed to build: exit status 1
[2021-05-04T15:49:28.222787831Z] /.app_platform/util.sh: line 154: printf: write error: Is a directory
[2021-05-04T15:49:28.233541353Z] cat: /.app_platform/.tmp/tmp.AEZAXCruwm: Is a directory
[2021-05-04T15:49:28.410022555Z]
[2021-05-04T15:49:28.410147916Z] For documentation on the buildpacks used to build your app, please see:
[2021-05-04T15:49:28.410358291Z] Node.js: https://do.co/apps-buildpack-node
[2021-05-04T15:49:28.411740813Z]
[2021-05-04T15:49:28.412169311Z] ! Build failed (145)
我的gatsby-config.js是:
module.exports = {
siteMetadata: {
title: `Plat`,
description: `We build tools.`,
author: `@plat`,
// siteUrl:`https://www.coolsite.org`
siteUrl:`https://www.coolsite.org`
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pdf`,
path: `${__dirname}/src/pdf`,
},
},
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-transformer-sharp`,
options: {
// The option defaults to true
checkSupportedExtensions: false,
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/favicon.png`,
},
},
'gatsby-plugin-postcss',
{
resolve: `gatsby-source-strapi`,
options: {
apiURL:`https://mydigitaloceanserver.app`,
//apiURL: `http://localhost:1337`,
queryLimit: 5000,
contentTypes: [`post`, `category`,`user`,`tag`,`page`],
singleTypes: [`homepage`,`about`],
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
// CommonMark mode (default: true)
commonmark: true,
// Footnotes mode (default: true)
footnotes: true,
// Pedantic mode (default: true)
pedantic: true,
// GitHub Flavored Markdown mode (default: true)
gfm: true,
// Plugins configs
plugins: [
{
resolve: `@raae/gatsby-remark-oembed`,
options: {
// usePrefix defaults to false
// usePrefix: true is the same as ["oembed"]
usePrefix: ["oembed", "video","embed","script"],
providers: {
include: [
'Twitter',
'Instagram',
'Youtube',
'Vimeo',
'Codesanbox'
],
exclude: ["Reddit"]
}
}
}
],
},
},
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Product','Sku','Subscription', 'Price', 'Customer'],
secretKey: process.env.STRIPE_SECRET_KEY,
downloadFiles: true,
}
},
{
resolve: `gatsby-plugin-sitemap`,
options: {
// Exclude specific pages or groups of pages using glob parameters
// See: https://github.com/isaacs/minimatch
// The example below will exclude the single `path/to/page` and all routes beginning with `category`
exclude: [`/app/*`],
query: `
{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
nodes {
path
}
}
}`,
resolveSiteUrl: ({site}) => {
//Alternatively, you may also pass in an environment variable (or any location) at the beginning of your `gatsby-config.js`.
return site.siteMetadata.siteUrl
},
serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map(node => {
return {
url: `${site.siteMetadata.siteUrl}${node.path}`,
changefreq: `daily`,
priority: 0.7,
}
})
}
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
host: 'https://www.platformable.com',
sitemap: 'https://www.coolsite.org/sitemap.xml',
policy: [{ userAgent: '*', allow: '/',disallow: ['/app','/app/*'] }]
}
},
],
and this is my gatsby-node.js
const path = require(`path`);
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
const makeRequest = (graphql, request) => new Promise((resolve, reject) => {
// Query for nodes to use in creating pages.
resolve(
graphql(request).then(result => {
if (result.errors) {
reject(result.errors)
}
return result;
})
)
});
// Implement the Gatsby API “createPages”. This is called once the
// data layer is bootstrapped to let plugins create pages from data.
exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions;
const getPosts = makeRequest(graphql, `
{
allStrapiPost {
edges {
node {
id
title
slug
}
}
}
}
`).then(result => {
// Create pages for each article.
result.data.allStrapiPost.edges.forEach(({ node }) => {
createPage({
path: `/${node.slug}`,
component: path.resolve(`src/templates/blog-post.js`),
context: {
slug:node.slug
},
})
})
});
// Query for articles nodes to use in creating pages.
return getPosts;
};
exports.sourceNodes = ({actions})=> {
const {createTypes} = actions;
const typeDefs = `
type StrapiAbout implements Node {
content: String
}
type StrapiPost implements Node {
slug: String
}
`
createTypes(typeDefs);
}
// Implement the Gatsby API “onCreatePage”. This is
// called after every page is created.
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions
// Only update the `/app` page.
if (page.path.match(/^\/app/)) {
// page.matchPath is a special key that's used for matching pages
// with corresponding routes only on the client.
page.matchPath = "/app/*"
// Update the page.
createPage(page)
}
}
我只在DigitalOcean上有这个问题。在Vercel或Netlify上部署时,它工作正常
我遗漏了什么吗?缺少细节或实现,但是,如果它在其他CD工具上正常工作,那么环境之间的节点版本似乎不匹配 通常(例如在Netlify中),您可以在项目根目录中设置一个
.nvmrc
文件,其中只包含节点版本,并且在部署过程中,CI工具会使用该版本安装依赖项
在DigitalOcean中,似乎需要使用package.json
设置它,如:
{
"engines" : {
"node" : "12.19.0"
}
}
通过Node-v
检查节点版本,并正确设置引擎
,以强制DigitalOcean安装特定节点版本的依赖项
此外,请尝试将checkSupportedExtensions
更改为其默认值:
{
resolve: `gatsby-transformer-sharp`,
options: {
// The option defaults to true
checkSupportedExtensions: true,
},
},
嗨,谢谢你的回复。我已经检查了我的节点版本,它是14.16.1,我添加了该版本的引擎,但仍然失败。关于
checkSupportedExtensions:true,
谢谢,将checkSupportedExtensions:false更改为true有效,这很奇怪,因为默认情况下它应该是true。谢谢刚刚添加了一个新页面,现在它不再工作了。DigitalOceane上有点奇怪是的,我检查了那个信息,我想是和盖茨比图像插件有关,只是更新了它,部署成功了。我将阅读关于迁移到盖茨比插件图像的文章,我已经做了,但肯定遗漏了一些东西。我会让你知道的