gpt4 book ai didi

javascript - netlify dev 开始无限循环

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:08:22 25 4
gpt4 key购买 nike

我正在努力添加环境变量来为 Netlify 函数进行条件切换。当我运行 CONTEXT=development netlify dev 时,我陷入了无限循环,Lambda 服务器不断切换端口。

Link on AWS functionspackage.json

yarn develop
yarn run v1.12.3
$ CONTEXT=development netlify dev
◈ Netlify Dev ◈
◈ Injected build setting env var: GATSBY_DEV_GITHUB_CLIENT_ID
◈ Injected build setting env var: GATSBY_DEV_GITHUB_CLIENT_SECRET
◈ Injected build setting env var: GATSBY_DEV_HOST_URL
◈ Injected build setting env var: GATSBY_FUNCTION_PASSWORD
◈ Injected build setting env var: GATSBY_GITHUB_CLIENT_ID
◈ Injected build setting env var: GATSBY_GITHUB_CLIENT_SECRET
◈ Injected build setting env var: GATSBY_HOST_URL
◈ Injected build setting env var: GATSBY_DEV_FUNCTION_PASSWORD
◈ Starting Netlify Dev with gatsby
Waiting for localhost:8000.
◈ Lambda server is listening on 34567
$ npm run develop
npm WARN lifecycle The node binary used for scripts is /var/folders/s7/vtbv89nd3f99nlx5y9h94qk00000gn/T/yarn--1560352104668-0.36838903564793/node but npm is using /Users/skok/.nvm/versions/node/v11.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> gatsby-dev-blog-starter@0.1.0 develop /Users/skok/dev/gatsby-dev-blog-starter
> CONTEXT=development netlify dev

.◈ Netlify Dev ◈
.◈ Starting Netlify Dev with gatsby
Waiting for localhost:8000.
◈ Lambda server is listening on 55396
$ npm run develop
.npm WARN lifecycle The node binary used for scripts is /var/folders/s7/vtbv89nd3f99nlx5y9h94qk00000gn/T/yarn--1560352107238-0.9451571250276476/node but npm is using /Users/skok/.nvm/versions/node/v11.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> gatsby-dev-blog-starter@0.1.0 develop /Users/skok/dev/gatsby-dev-blog-starter
> CONTEXT=development netlify dev

..◈ Netlify Dev ◈
.◈ Starting Netlify Dev with gatsby
.Waiting for localhost:8000.
◈ Lambda server is listening on 55412
$ npm run develop
.npm WARN lifecycle The node binary used for scripts is /var/folders/s7/vtbv89nd3f99nlx5y9h94qk00000gn/T/yarn--1560352109773-0.46483751576396815/node but npm is using /Users/skok/.nvm/versions/node/v11.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> gatsby-dev-blog-starter@0.1.0 develop /Users/skok/dev/gatsby-dev-blog-starter
> CONTEXT=development netlify dev

...◈ Netlify Dev ◈
.. ◈ Starting Netlify Dev with gatsby
.Waiting for localhost:8000.
◈ Lambda server is listening on 55436
$ npm run develop
..npm WARN lifecycle The node binary used for scripts is /var/folders/s7/vtbv89nd3f99nlx5y9h94qk00000gn/T/yarn--1560352112263-0.5329314860894214/node but npm is using /Users/skok/.nvm/versions/node/v11.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> gatsby-dev-blog-starter@0.1.0 develop /Users/skok/dev/gatsby-dev-blog-starter
> CONTEXT=development netlify dev

Netlify 构建日志

8:01:43 AM: Build ready to start
8:01:52 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
8:01:52 AM: build-image tag: v3.3.2
8:01:52 AM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045
8:01:52 AM: Fetching cached dependencies
8:01:52 AM: Starting to download cache of 255.0KB
8:01:52 AM: Finished downloading cache in 119.733265ms
8:01:52 AM: Starting to extract cache
8:01:52 AM: Failed to fetch cache, continuing with build
8:01:52 AM: Starting to prepare the repo for build
8:01:53 AM: No cached dependencies found. Cloning fresh repo
8:01:53 AM: git clone https://github.com/iamskok/gatsby-dev-blog-starter
8:01:56 AM: Preparing Git Reference refs/heads/master
8:01:56 AM: Found netlify.toml. Overriding site configuration
8:01:56 AM: Different publish path detected, going to use the one specified in the toml file: 'public' versus 'public/' in the site
8:01:56 AM: Different build command detected, going to use the one specified in the toml file: 'yarn build' versus 'CONTEXT=production gatsby build' in the site
8:01:56 AM: Different functions path detected, going to use the one specified in the toml file: '.netlify/functions' versus '' in the site
8:01:56 AM: Different base path detected, going to use the one specified in the toml file: '/' versus '' in the site
8:01:56 AM: Creating functions prep folder
8:01:56 AM: Starting build script
8:01:56 AM: Installing dependencies
8:01:58 AM: Downloading and installing node v11.5.0...
8:01:58 AM: Downloading https://nodejs.org/dist/v11.5.0/node-v11.5.0-linux-x64.tar.xz...
8:01:59 AM: 0.1%
8:01:59 AM:
##
8:01:59 AM: 2.9%
8:01:59 AM:
### 4.7%
8:01:59 AM:
####
8:01:59 AM: 5.9%
8:01:59 AM:
##### 7.3%
8:01:59 AM: #####
8:01:59 AM: 8.2%
8:01:59 AM:
######
8:01:59 AM: 9.0%
8:01:59 AM:
#######
8:01:59 AM: 10.1%
8:01:59 AM:
########
8:01:59 AM: 11.7%
8:01:59 AM:
#########
8:01:59 AM: 13.0%
8:02:00 AM:
###########
8:02:00 AM: 15.5%
8:02:00 AM:
############ 1
8:02:00 AM: 7.0%
8:02:00 AM:
############
8:02:00 AM: 17.9%
8:02:00 AM:
#############
8:02:00 AM: 18.4%
8:02:00 AM:
############## 20.2%
8:02:00 AM:
############### 21.0%
8:02:01 AM:
###############
8:02:01 AM: 21.8%
8:02:01 AM:
################
8:02:01 AM: 22.7%
8:02:01 AM:
################
8:02:01 AM: 23.6%
8:02:01 AM:
#################
8:02:01 AM: 24.4%
8:02:02 AM:
#################
8:02:02 AM: 24.9%
8:02:02 AM:
##################
8:02:02 AM: 26.3%
8:02:02 AM:
###################
8:02:02 AM: 26.9%
8:02:02 AM:
######################
8:02:02 AM: 30.7%
8:02:03 AM:
######################
8:02:03 AM: 31.0%
8:02:03 AM:
#######################
8:02:03 AM: 32.8%
8:02:03 AM:
#######################
8:02:03 AM: 33.3%
8:02:03 AM:
########################
8:02:03 AM: 34.1%
8:02:04 AM:
#########################
8:02:04 AM: 35.2%
8:02:04 AM:
########################### 38.5%
8:02:04 AM:
###########################
8:02:04 AM: 38.7%
8:02:04 AM:
############################
8:02:04 AM: 39.7%
8:02:04 AM:
#############################
8:02:04 AM: 41.0%
8:02:04 AM:
##############################
8:02:04 AM: 41.8%
8:02:04 AM:
###############################
8:02:04 AM: 43.2%
8:02:04 AM:
################################
8:02:04 AM: 44.7%
8:02:05 AM:
################################
8:02:05 AM: 45.6%
8:02:05 AM:
#################################
8:02:05 AM: 46.4%
8:02:05 AM:
##################################
8:02:05 AM: 47.5%
8:02:05 AM:
##################################
8:02:05 AM: 48.5%
8:02:05 AM:
###################################
8:02:05 AM: 49.4%
8:02:05 AM:
####################################
8:02:05 AM: 50.4%
8:02:05 AM:
##################################### 51.8%
8:02:05 AM:
######################################
8:02:05 AM: 53.1%
8:02:05 AM:
#######################################
8:02:05 AM: 54.4%
8:02:06 AM:
#######################################
8:02:06 AM: 54.8%
8:02:06 AM:
########################################
8:02:06 AM: 56.3%
8:02:06 AM:
#########################################
8:02:06 AM: 57.0%
8:02:06 AM:
#########################################
8:02:06 AM: 57.7%
8:02:06 AM:
#########################################
8:02:06 AM: 58.0%
8:02:06 AM:
######################################### 5
8:02:06 AM: 8.2%
8:02:06 AM:
##########################################
8:02:06 AM: 58.6%
8:02:07 AM:
##########################################
8:02:07 AM: 59.4%
8:02:08 AM:
##########################################
8:02:08 AM: 59.5%
8:02:08 AM:
##########################################
8:02:08 AM: 59.5%
8:02:08 AM:
##############################################
8:02:08 AM: 64.0%
8:02:08 AM:
###################################################
8:02:08 AM: 71.0%
8:02:08 AM:
###################################################
8:02:08 AM: 72.0%
8:02:09 AM:
####################################################
8:02:09 AM: 73.0%
8:02:09 AM:
##################################################### 73.7%
8:02:09 AM:
#####################################################
8:02:09 AM: 74.2%
8:02:09 AM:
######################################################
8:02:09 AM: 75.0%
8:02:09 AM:
######################################################
8:02:09 AM: 75.7%
8:02:09 AM:
#####################################
8:02:09 AM: ################# 76.2%
8:02:10 AM:
#######################################################
8:02:10 AM: 77.6%
8:02:10 AM:
#######################################################
8:02:10 AM: 77.7%
8:02:10 AM:
#################################################
8:02:10 AM: ####### 78.1%
8:02:10 AM:
######################################################## 78.8%
8:02:11 AM: #
8:02:11 AM: ##############################################
8:02:11 AM: ########### 81.9%
8:02:11 AM:
########################################################### 82.4
8:02:11 AM: %
8:02:11 AM:
###########################################################
8:02:11 AM: 82.8%
8:02:11 AM:
############################################################
8:02:11 AM: 84.7%
8:02:11 AM:
############################################################# 85.7%
8:02:12 AM:
############################################################## 86.5%
8:02:12 AM:
#####################################################
8:02:12 AM: ######### 86.6%
8:02:12 AM:
#############################
8:02:12 AM: ################################## 87.5%
8:02:12 AM:
############################################################### 88.1%
8:02:13 AM:
############################################################### 88.3%
8:02:13 AM:
################################################################
8:02:13 AM: 89.0%
8:02:13 AM:
#############################################################
8:02:13 AM: ### 89.5%
8:02:13 AM:
#################################################################
8:02:13 AM: 90.9%
8:02:13 AM:
##################################################################
8:02:13 AM: 91.7%
8:02:13 AM:
################################################################## 92.5%
8:02:14 AM:
###################################################################
8:02:14 AM: 94.1%
8:02:14 AM:
####################################################################
8:02:14 AM: 94.8%
8:02:14 AM:
####################################################################
8:02:14 AM: 95.6%
8:02:14 AM:
#####################################################################
8:02:14 AM: 96.1%
8:02:14 AM:
##################################################################### 96.5%
8:02:14 AM:
##################################################################### 97.1%
8:02:14 AM:
###################################################
8:02:14 AM: ################### 97.6%
8:02:14 AM:
###################################################################### 98.2%
8:02:14 AM:
####################################################################### 98.6%
8:02:15 AM:
###################################################################
8:02:15 AM: #### 99.0%
8:02:15 AM:
######################################################################
8:02:15 AM: # 99.8%
8:02:15 AM:
########################################################################
8:02:15 AM: 100.0%
8:02:15 AM: Computing checksum with sha256sum
8:02:15 AM: Checksums matched!
8:02:17 AM: Now using node v11.5.0 (npm v6.4.1)
8:02:18 AM: Attempting ruby version 2.6.2, read from environment
8:02:19 AM: Using ruby version 2.6.2
8:02:19 AM: Using PHP version 5.6
8:02:19 AM: Started restoring cached node modules
8:02:19 AM: Finished restoring cached node modules
8:02:19 AM: Started restoring cached yarn cache
8:02:19 AM: Finished restoring cached yarn cache
8:02:19 AM: Installing yarn at version 1.3.2
8:02:19 AM: Installing Yarn!
8:02:19 AM: > Downloading tarball...
8:02:19 AM: [1/2]: https://yarnpkg.com/downloads/1.3
8:02:19 AM: .2/yarn-v1.3.2.tar.gz --> /tmp/yarn.tar.gz.r76iL9IFsO
8:02:19 AM: % Total % Receiv
8:02:19 AM: ed % Xferd Average Speed Time Time Time Current
8:02:19 AM: Dload Upload Total Spent Left Sp
8:02:19 AM: eed
8:02:19 AM:
0 0 0 0 0 0
8:02:19 AM: 0 0 --:--:-- --:--:-- --:--:-- 0
8:02:20 AM:
100 91 100 91 0 0 312 0 --:--:-- --:--:-- --:--:-- 313
8:02:21 AM:
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
8:02:21 AM:
100 608 0 608 0 0 487 0 --:--:-- 0:00:01 --:--:-- 593k
8:02:21 AM:
100 865k 100 865k 0 0 514k 0 0:00
8:02:21 AM: :01 0:00:01 --:--:-- 514k
8:02:21 AM: [2/2]: https://
8:02:21 AM: yarnpkg.com/downloads/1.3.2/yarn-v1.3.2.tar.gz.asc --> /tmp/yarn.tar.gz.
8:02:21 AM: r76iL9IFsO.asc
8:02:21 AM:
100 95 100 95 0 0 2206 0 --:--:-- --:--:-- --:--:-
8:02:21 AM: - 2206
8:02:21 AM:
0 0 0 0 0 0 0 0 --:--:--
8:02:21 AM: --:--:-- --:--:-- 0
100 612 0 612 0 0 3167 0 --:--:-- --:--:-- --:--:-- 597k
8:02:21 AM:
100 1027 100 1027 0 0 4452 0 --:--:-- --:--:-- --
8:02:21 AM: :--:-- 4452
8:02:21 AM: > Verifying integrity...
8:02:21 AM: gpg: Signature made Thu 02 Nov 2017 04:44:10 PM UTC using RSA key ID FD2497F5
8:02:21 AM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
8:02:21 AM: gpg: Note: This key has expired!
8:02:21 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907 BBB7 1646 B01B
8:02:21 AM: 86E5 0310
8:02:21 AM: Subkey fingerprint: 6A01 0C51 6600 6599 AA17 F081 46C2 130D FD24 97F5
8:02:21 AM: > GPG signature looks good
8:02:21 AM: > Extracting to ~/.yarn...
8:02:21 AM: > Adding to $PATH...
8:02:21 AM: > We've added the following to your /opt/buildhome/.profile
8:02:21 AM: > If this isn't the profile of your current shell then please add the following to your correct profile:
8:02:21 AM: export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
8:02:21 AM:
8:02:22 AM: > Successfully installed Yarn 1.3.2! Please open another terminal where the `yarn` command will now be available.
8:02:22 AM: Installing NPM modules using Yarn version 1.3.2
8:02:23 AM: yarn install v1.3.2
8:02:23 AM: (node:1370) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
8:02:23 AM: [1/4] Resolving packages...
8:02:24 AM: [2/4] Fetching packages...
8:02:42 AM: info fsevents@1.2.8: The platform "linux" is incompatible with this module.
8:02:42 AM: info "fsevents@1.2.8" is an optional dependency and failed compatibility check. Excluding it from installation.
8:02:42 AM: [3/4] Linking dependencies...
8:02:42 AM: warning "gatsby > pnp-webpack-plugin > ts-pnp@1.1.2" has unmet peer dependency "typescript@*".
8:02:42 AM: warning "gatsby > mini-css-extract-plugin > schema-utils > ajv-errors@1.0.1" has unmet peer dependency "ajv@>=5.0.0".
8:02:42 AM: warning " > gatsby-plugin-sass@2.0.11" has unmet peer dependency "node-sass@^4.9.0".
8:02:42 AM: warning "gatsby-plugin-sass > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
8:02:50 AM: [4/4] Building fresh packages...
8:02:55 AM: Done in 32.09s.
8:02:55 AM: NPM modules installed using Yarn
8:02:55 AM: (node:1495) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
8:02:56 AM: Started restoring cached go cache
8:02:56 AM: Finished restoring cached go cache
8:02:56 AM: unset GOOS;
8:02:56 AM: unset GOARCH;
8:02:56 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
8:02:56 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
8:02:56 AM: go version >&2;
8:02:56 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
8:02:56 AM: go version go1.12 linux/amd64
8:02:56 AM: Installing missing commands
8:02:56 AM: Verify run directory
8:02:56 AM: Executing user command: yarn build
8:02:56 AM: yarn run v1.3.2
8:02:56 AM: (node:1548) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
8:02:56 AM: $ gatsby build
8:02:59 AM: success open and validate gatsby-configs — 0.034 s
8:03:00 AM: success load plugins — 0.785 s
8:03:00 AM: success onPreInit — 0.006 s
8:03:00 AM: success delete html and css files from previous builds — 0.006 s
8:03:00 AM: success initialize cache — 0.009 s
8:03:00 AM: success copy gatsby files — 0.027 s
8:03:00 AM: success onPreBootstrap — 0.010 s
8:03:00 AM: success source and transform nodes — 0.172 s
8:03:00 AM: success building schema — 0.413 s
8:03:00 AM: success createPages — 0.041 s
8:03:00 AM: success createPagesStatefully — 0.036 s
8:03:00 AM: success onPreExtractQueries — 0.003 s
8:03:00 AM: success update schema — 0.035 s
8:03:01 AM: success extract queries from components — 0.203 s
8:03:01 AM: success run static queries — 0.015 s — 4/4 282.72 queries/second
8:03:07 AM: success run page queries — 6.163 s — 8/8 1.30 queries/second
8:03:07 AM: success write out page data — 0.004 s
8:03:07 AM: success write out redirect data — 0.001 s
8:03:36 AM: success Build manifest and related icons — 0.217 s
8:03:36 AM: success onPostBootstrap — 0.219 s
8:03:36 AM: info bootstrap finished - 39.680 s
8:04:06 AM: success Building production JavaScript and CSS bundles — 30.272 s
8:04:10 AM: success Building static HTML for pages — 3.994 s — 8/8 12.70 pages/second
8:04:10 AM: info Done building in 74.085 sec
8:04:11 AM: Done in 74.58s.
8:04:11 AM: Function Dir: /opt/build/repo/.netlify/functions
8:04:11 AM: TempDir: /tmp/zisi-753014076
8:04:11 AM: Prepping functions with zip-it-and-ship-it 0.3.1
8:04:12 AM: [ { path: '/tmp/zisi-753014076/access-token.zip', runtime: 'js' },
8:04:12 AM: { path: '/tmp/zisi-753014076/auth-redirect.zip', runtime: 'js' },
8:04:12 AM: { path: '/tmp/zisi-753014076/auth.zip', runtime: 'js' },
8:04:12 AM: { path: '/tmp/zisi-753014076/vault.zip', runtime: 'js' } ]
8:04:12 AM: Prepping functions complete
8:04:12 AM: Caching artifacts
8:04:12 AM: Started saving node modules
8:04:12 AM: Finished saving node modules
8:04:12 AM: Started saving yarn cache
8:04:12 AM: Finished saving yarn cache
8:04:12 AM: Started saving pip cache
8:04:12 AM: Finished saving pip cache
8:04:12 AM: Started saving emacs cask dependencies
8:04:12 AM: Finished saving emacs cask dependencies
8:04:12 AM: Started saving maven dependencies
8:04:12 AM: Finished saving maven dependencies
8:04:12 AM: Started saving boot dependencies
8:04:12 AM: Finished saving boot dependencies
8:04:12 AM: Started saving go dependencies
8:04:12 AM: Finished saving go dependencies
8:04:15 AM: Build script success
8:04:15 AM: Starting to deploy site from 'public'
8:04:15 AM: Creating deploy tree
8:04:15 AM: 15 new files to upload
8:04:15 AM: 0 new functions to upload
8:04:17 AM: Starting post processing
8:04:17 AM: Minifying bundle
8:04:19 AM: Minifying bundle
8:04:22 AM: Minifying bundle
8:04:24 AM: Minifying bundle
8:04:27 AM: Minifying bundle
8:04:29 AM: Minifying bundle
8:04:31 AM: Post processing done
8:04:32 AM: Site is live
8:04:46 AM: Finished processing build request in 2m53.782877402s
8:04:46 AM: Shutting down logging, 0 messages pending

更新:

我正在关注 this 关于 Gatsby 项目中的 .env 变量的帖子。

它建议引入另一个变量,例如GATSBY_ACTIVE_ENV 并手动设置。我能够按预期运行 GATSBY_ACTIVE_ENV=development netlify dev,尽管在​​ package.json 的脚本下添加了 GATSBY_ACTIVE_ENV=development netlify dev 命令并运行yarn develop 导致无限循环。进入循环后,如果不进入循环就无法再运行 GATSBY_ACTIVE_ENV=development netlify dev

这个问题也发布在Netlify Forum

最佳答案

您使用的函数路径是生产中的代理路径(/.netlify/functions/)。在本地使用 (netlify dev) netlify 开发工作流将使用该路径来监视函数的编译更改。

将函数目录移动到不同的位置(例如 /src/functions)并更改 netlify.toml build.functions = "functions"。 Netlify 将使用该目录来获取您的捆绑脚本。

使用捆绑命令在您的工作流中构建您的函数。 Netlify 有一个名为 netlify-lambda 的 cli,您可以使用它 (yarn add netlify-lambda -D)。将构建命令添加到您的构建工作流中。

$ netlify-lambda build src/functions

netlify dev死循环的常见原因

以下是无效的,将导致 netlify dev 不断调用自身函数

  • 将函数源设置为与构建相同的目录
  • scripts.development 命令包中包含 netlify dev 命令。 (例如`"development": "npm run netlify dev")

注意:在 Netlify 上使用函数时,您需要将依赖项捆绑到函数中,否则它们在部署时不会解析。

关于javascript - netlify dev 开始无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56565584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com