Я развертываю веб-сайт, созданный с помощью Nuxt. js для Netlify. Я запускаю команду run npm generate
локально, и она работает. Но выполнение той же команды в Netlify завершается с ошибкой ниже. Полный журнал связан в конце вопроса. Как я могу это исправить?
1:26:30 PM: FATAL (intermediate value).flat is not a function
1:26:30 PM: at prepareFonts (node_modules/nuxt-font-loader-strategy/lib/utils/fontFace.js:56:8)
1:26:30 PM: at process._tickCallback (internal/process/next_tick.js:68:7)
1:26:30 PM: at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
1:26:30 PM: at startup (internal/bootstrap/node.js:283:19)
1:26:30 PM: at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
1:26:30 PM: ╭────────────────────────────────────────────────────────────╮
1:26:30 PM: │ │
1:26:30 PM: │ ✖ Nuxt Fatal Error │
1:26:30 PM: │ │
1:26:30 PM: │ TypeError: (intermediate value).flat is not a function │
1:26:30 PM: │ │
1:26:30 PM: ╰────────────────────────────────────────────────────────────╯
Я нашел этот файл. js, но не вижу в этом ничего плохого.
`
import { extname } from 'path'
import { paramCase, snakeCase } from 'change-case'
// Font-Face
const FONTFACE_PROPERTIES = {
fontFamily: null,
fontUnicodeRange: null,
fontVariant: 'normal',
fontFeatureSettings: 'normal',
fontStretch: 'normal',
fontWeight: 'normal',
fontStyle: 'normal',
fontDisplay: 'swap'
}
const DEFAULT_FONT_EXTENSIONS = ['woff2', 'woff']
const DEFAULT_CLASS_PATTERN = '[family]_[variant]_[featureSettings]_[stretch]_[weight]_[style]'
export function getFontClasses (pattern, set, properties) {
pattern = pattern || DEFAULT_CLASS_PATTERN
const className = Object.keys(properties).reduce((result, key) => {
let name = key.replace(/^font/, '')
name = name.replace(/^.{1}/, name[0].toLowerCase())
let value = properties[String(key)]
if (name === 'family') {
value = set
}
result = result.replace(`[${name}]`, value)
return result
}, pattern)
return [`font_${set}`, `font_${className}`]
}
export async function prepareFonts (options, resolve, kebabCaseProps = true) {
const { fonts, classPattern } = options
return (await Promise.all(fonts.map((font) => {
const fileExtensions = getFileExtensions(font)
return font.fontFaces.map((face) => {
const sources = prepareSrc(face.src, fileExtensions, resolve)
const properties = getProperties(
Object.assign({ fontFamily: `${font.fontFamily}` }, face),
kebabCaseProps ? paramCase : name => name
)
const set = snakeCase(font.fontFamily)
return {
classes: getFontClasses(classPattern, set, properties),
properties,
sources,
set,
preload: face.preload || false,
local: [].concat(face.local || [])
}
})
}))).flat() /*This is where the error is reported to be on Netlify*/
}
export function createFontFace (font, baseUrl) {
const props = font.properties
const options = {
display: props.fontDisplay,
style: props.fontStyle,
weight: props.fontWeight,
unicodeRange: props.fontUnicodeRange,
variant: props.fontVariant,
featureSettings: props.fontFeatureSettings,
stretch: props.fontStretch
}
const src = `url(${baseUrl + font.sources[0].path})`
return new FontFace(props.fontFamily.replace(/'/g, ''), src, options)
}
function getFileExtensions (font) {
if (Array.isArray(font.fileExtensions) && font.fileExtensions.length > 0) {
return font.fileExtensions
} else {
return DEFAULT_FONT_EXTENSIONS
}
}
function getFormat (path) {
return extname(path).replace(/^\./, '')
}
function getProperties (face, transform = paramCase) {
return Object.keys(FONTFACE_PROPERTIES).reduce((result, prop) => {
const value = face[prop] || FONTFACE_PROPERTIES[prop]
if (value) {
result[transform(prop)] = value
}
return result
}, {})
}
function prepareSrc (src, fileExtensions, pathResolve) {
return fileExtensions.map((fileExtension) => {
const filePath = src + '.' + fileExtension
return {
path: pathResolve(filePath),
format: getFormat(filePath)
}
})
}
Полный журнал:
1:25:50 PM: Build ready to start
1:25:55 PM: build-image version: 2dbd444fcdce00cf06325060a8238d5ae3e86774
1:25:55 PM: build-image tag: v3.3.7
1:25:55 PM: buildbot version: 11918e084194721d200458438c92ff8180b3b56c
1:25:55 PM: Fetching cached dependencies
1:25:55 PM: Starting to download cache of 254.9KB
1:25:55 PM: Finished downloading cache in 64.114893ms
1:25:55 PM: Starting to extract cache
1:25:55 PM: Failed to fetch cache, continuing with build
1:25:55 PM: Starting to prepare the repo for build
1:25:55 PM: No cached dependencies found. Cloning fresh repo
1:25:55 PM: git clone https://github.com/simeon9696/indecisivefoodie-v2
1:25:56 PM: Preparing Git Reference refs/heads/master
1:25:57 PM: Starting build script
1:25:57 PM: Installing dependencies
1:25:58 PM: v10.19.0 is already installed.
1:25:59 PM: Now using node v10.19.0 (npm v6.13.4)
1:25:59 PM: Attempting ruby version 2.6.2, read from environment
1:26:01 PM: Using ruby version 2.6.2
1:26:01 PM: Using PHP version 5.6
1:26:01 PM: Started restoring cached node modules
1:26:01 PM: Finished restoring cached node modules
1:26:01 PM: Installing NPM modules using NPM version 6.13.4
1:26:22 PM: > fibers@4.0.2 install /opt/build/repo/node_modules/fibers
1:26:22 PM: > node build.js || nodejs build.js
1:26:22 PM: `linux-x64-64-glibc` exists; testing
1:26:22 PM: Binary is fine; exiting
1:26:22 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/core-js
1:26:22 PM: > node -e "try{require('./postinstall')}catch(e){}"
1:26:22 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling
JavaScript standard library!
1:26:22 PM: The project needs your help! Please consider supporting of core-js on Open Collective
or Patreon:
1:26:22 PM: > https://opencollective.com/core-js
1:26:22 PM: > https://www.patreon.com/zloirock
1:26:22 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job
-)
1:26:22 PM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/ejs
1:26:22 PM: > node ./postinstall.js
1:26:23 PM: Thank you for installing EJS: built with the Jake JavaScript build tool
(https://jakejs.com/)
1:26:23 PM: > nuxt@2.11.0 postinstall /opt/build/repo/node_modules/nuxt
1:26:23 PM: > opencollective || exit 0
1:26:23 PM: :-:
1:26:23 PM: .==-+:
1:26:23 PM: .==. :+- .-=-
1:26:23 PM: .==. :==++-+=.
1:26:23 PM: :==. -**: :+=.
1:26:23 PM: :+- :*+++. .++.
1:26:23 PM: :+- -*= .++: .=+.
1:26:23 PM: -+: =*- .+*: .=+:
1:26:23 PM: -+: .=*- .=*- =+:
1:26:23 PM: .==: .+*: -*- -+-
1:26:23 PM: .=+:.....:+*-.........:=*=..=*-
1:26:23 PM: .-=------=++============++====:
1:26:23 PM: Thanks for installing nuxtjs
1:26:23 PM: Please consider donating to our open collective
1:26:23 PM: to help us maintain this package.
1:26:23 PM: Number of contributors: 229
1:26:23 PM: Number of backers: 308
1:26:23 PM: Annual budget: $75,947
1:26:23 PM: Current balance: $23,984
1:26:23 PM: Donate: https://opencollective.com/nuxtjs/donate
1:26:25 PM: npm
1:26:25 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11
(node_modules/watchpack/node_modules/fsevents):
1:26:25 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
1:26:25 PM: npm WARN
1:26:25 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
1:26:25 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
1:26:25 PM: added 1141 packages from 517 contributors and audited 11182 packages in 22.508s
1:26:26 PM: 39 packages are looking for funding
1:26:26 PM: run `npm fund` for details
1:26:26 PM: found 18 moderate severity vulnerabilities
1:26:26 PM: run `npm audit fix` to fix them, or `npm audit` for details
1:26:26 PM: NPM modules installed
1:26:26 PM: Started restoring cached go cache
1:26:26 PM: Finished restoring cached go cache
1:26:26 PM: unset GOOS;
1:26:26 PM: unset GOARCH;
1:26:26 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
1:26:26 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
1:26:26 PM: go version >&2;
1:26:26 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
1:26:26 PM: go version go1.12 linux/amd64
1:26:26 PM: Installing missing commands
1:26:26 PM: Verify run directory
1:26:27 PM: Executing user command: npm run generate
1:26:27 PM: > indecisive-foodie@1.0.0 generate /opt/build/repo
1:26:27 PM: > nuxt generate
1:26:30 PM: WARN No .env file found in /opt/build/repo.
1:26:30 PM: FATAL (intermediate value).flat is not a function
1:26:30 PM: at prepareFonts (node_modules/nuxt-font-loader-strategy/lib/utils/fontFace.js:56:8)
1:26:30 PM: at process._tickCallback (internal/process/next_tick.js:68:7)
1:26:30 PM: at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
1:26:30 PM: at startup (internal/bootstrap/node.js:283:19)
1:26:30 PM: at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
1:26:30 PM: ╭────────────────────────────────────────────────────────────╮
1:26:30 PM: │ │
1:26:30 PM: │ ✖ Nuxt Fatal Error │
1:26:30 PM: │ │
1:26:30 PM: │ TypeError: (intermediate value).flat is not a function │
1:26:30 PM: │ │
1:26:30 PM: ╰────────────────────────────────────────────────────────────╯
1:26:30 PM: npm
1:26:30 PM: ERR! code
1:26:30 PM: ELIFECYCLE
1:26:30 PM: npm
1:26:30 PM: ERR!
1:26:30 PM: errno 1
1:26:30 PM: npm
1:26:30 PM: ERR! indecisive-foodie@1.0.0 generate: `nuxt generate`
1:26:30 PM: npm
1:26:30 PM: ERR! Exit status 1
1:26:30 PM: npm
1:26:30 PM: ERR!
1:26:30 PM: npm ERR! Failed at the indecisive-foodie@1.0.0 generate script.
1:26:30 PM: npm ERR!
1:26:30 PM: This is probably not a problem with npm. There is likely additional logging output
above.
1:26:31 PM: npm
1:26:31 PM: ERR! A complete log of this run can be found in:
1:26:31 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-03-18T17_26_30_664Z-debug.log
1:26:31 PM: Skipping functions preparation step: no functions directory set
1:26:31 PM: Caching artifacts
1:26:31 PM: Started saving node modules
1:26:31 PM: Finished saving node modules
1:26:31 PM: Started saving pip cache
1:26:32 PM: Finished saving pip cache
1:26:32 PM: Started saving emacs cask dependencies
1:26:32 PM: Finished saving emacs cask dependencies
1:26:32 PM: Started saving maven dependencies
1:26:32 PM: Finished saving maven dependencies
1:26:32 PM: Started saving boot dependencies
1:26:32 PM: Finished saving boot dependencies
1:26:32 PM: Started saving go dependencies
1:26:32 PM: Finished saving go dependencies
1:26:36 PM: Error running command: Build script returned non-zero exit code: 1
1:26:36 PM: Failing build: Failed to build site
1:26:36 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
1:26:36 PM: Finished processing build request in 41.011761064s