经过更改,我的网站不再部署在Netlify中。依赖关系? AWS Lambda?

时间:2019-12-15 13:29:15

标签: node.js netlify contentful

我正在尝试通过Netlify从GitLab进行部署。是Node.js从Contentful中提取的。该网站的正常运作和部署情况一直持续到11月下旬,12月初。

在部署日志中,跳出了两件事:

> babel-node services/getcontent.js install
Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
> Starting import...
> Getting content for article
(node:1280) UnhandledPromiseRejectionWarning: #<Object>
(node:1280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

 > Location: "/opt/build/repo/.babelrc"
 Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
 [11:58:23 AM] Compiled server in 18s
 [11:59:35 AM] Compiled client in 1m
 > Failed to build
 { Error: (client) ./pages/static-page.js
 Module not found: Error: Can't resolve 'services/contentfulData/aboutPage.json' in '/opt/build/repo/pages'
 @ ./pages/static-page.js 79:13-62

除非是某些核心依赖问题(可能是),否则我怀疑罪魁祸首可能是我的网站使用的这段代码(https://gist.github.com/tomsansome/bac869b17a4877817674993df1d67f27):

import fs from 'fs'
import path from 'path'
import { createClient } from 'contentful'

const SPACE = process.env.CONTENTFUL_SPACE
const TOKEN = process.env.CONTENTFUL_TOKEN

const client = createClient({
  space: SPACE,
  accessToken: TOKEN
})

const types = [
  'pageHome'
]

export const getcontent = async () => {
  console.log('> Starting import...')
  for (const type of types) {
    console.log('> Getting content for', type)
    const entries = await client.getEntries({
      content_type: type,
      include: 3
    })
    if (entries.total === 1) {
      const { fields } = entries.items[0]
      fs.writeFileSync(
        path.join(__dirname, '..', 'data', `${type}.json`),
        JSON.stringify(fields)
      )
      console.log('> Content gotten and written for', type)
    }
  }
  return true
}

if (process.argv[2] === 'install') {
  getcontent()
}

对于上下文,这是package.json:

{
  "name": "psillow-app",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "dev": "node server",
    "build": "next build",
    "serve": "rm -rf node_modules/.cache && npm run getcontent && npm run generate-lqip && next build && next export && serve out",
    "export": "npm run getcontent && npm run generate-lqip && next build && next export && npm run build-functions && npm run move-redirects",
    "getcontent": "babel-node services/getcontent.js install",
    "generate-svg": "babel-node services/generateSVG.js",
    "generate-lqip": "babel-node services/generateLQIP.js",
    "serve-functions": "netlify-lambda serve functions",
    "build-functions": "cd functions && npm install && cd .. && netlify-lambda build functions",
    "move-redirects": "cp /opt/build/repo/services/_redirects /opt/build/repo/out/_redirects",
    "generate-redirects": "babel-node rewrite-url.js"
  },
    "dependencies": {
    "@babel/cli": "^7.1.2",
    "@babel/node": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.1.2",
    "@babel/preset-env": "^7.1.0",
    "@zeit/next-css": "^1.0.1",
    "@zeit/next-less": "^1.0.1",
    "antd": "^3.10.3",
    "aws-amplify": "^2.0.0",
    "aws-amplify-react": "^3.0.0",
    "babel-plugin-import": "^1.9.1",
    "babel-plugin-inline-import": "^3.0.0",
    "babel-plugin-inline-react-svg": "^1.0.0",
    "babel-plugin-styled-components": "^1.8.0",
    "contentful": "^7.0.5",
    "cross-env": "^6.0.0",
    "date-fns": "^2.0.0",
    "dotenv": "^8.0.0",
    "download": "^7.1.0",
    "express": "^4.16.4",
    "fast-safe-stringify": "^2.0.6",
    "file-loader": "^5.0.0",
    "fs-extra": "^8.0.0",
    "less": "^3.8.1",
    "less-plugin-clean-css": "^1.5.1",
    "lodash": "^4.17.11",
    "lqip": "^2.1.0",
    "markdown-to-jsx": "^6.8.3",
    "netlify-lambda": "^1.0.0",
    "next": "^7.0.2",
    "next-offline": "^4.0.0",
    "next-routes": "^1.4.2",
    "path-match": "^1.2.4",
    "purched-antd-icons": "^0.2.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-ga": "^2.5.3",
    "react-google-recaptcha": "^2.0.0",
    "react-instantsearch": "^6.0.0",
    "react-mailchimp-subscribe": "^2.0.2",
    "react-stack-grid": "^0.7.1",
    "react-styled-flexboxgrid": "^3.0.0",
    "resolve": "^1.8.1",
    "sitemap": "^5.0.0",
    "sqip": "^0.3.3",
    "styled-components": "^4.0.0",
    "styled-media-query": "^2.0.2",
    "uuid": "^3.3.2",
    "workbox-webpack-plugin": "^4.0.0"
  },

感谢您提供任何见解。我正在慢慢掌握这些系统,但是这些大量的代码被丢在了我身上,老实说,我不知道从哪里开始寻找。

0 个答案:

没有答案