首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在无服务器部署部署过程中出现错误"Cannot read property 'name‘of undefined“

在无服务器部署部署过程中出现错误"Cannot read property 'name‘of undefined“
EN

Stack Overflow用户
提问于 2021-02-23 00:50:40
回答 3查看 2.4K关注 0票数 0

当我运行SLS_DEBUG=* serverless deploy命令时,我得到错误Cannot read property 'name' of undefined,请帮助。日志和错误:

代码语言:javascript
复制
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command s3sync
Serverless: Load command s3sync:bucket
 
  Type Error ---------------------------------------------
 
  TypeError: Cannot read property 'name' of undefined
      at PluginManager.loadCommands (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:252:51)
      at PluginManager.addPlugin (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:105:10)
      at /usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:121:33
      at Array.forEach (<anonymous>)
      at PluginManager.loadAllPlugins (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:121:8)
      at Serverless.init (/usr/local/lib/node_modules/serverless/lib/Serverless.js:166:30)
      at /usr/local/lib/node_modules/serverless/scripts/serverless.js:73:7
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.15.1
     Framework Version:         2.25.2
     Plugin Version:            4.4.3
     SDK Version:               2.3.2
     Components Version:        3.7.0

我的serverless.yml:

代码语言:javascript
复制
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
#    docs.serverless.com
#
# Happy Coding!

service: blogserverlesstraining
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
frameworkVersion: '2'

provider:
  name: aws
  runtime: nodejs12.x
  lambdaHashingVersion: 20201221
  profile: MyServerlessAccount
  region: us-east-1
  stage: dev
  environment:
    tableNamePost: ${self:custom.tableNamePost}
    imageUploadBucket: ${self:custom.imagePostsBucket}
    region: ${self:provider.region}
    cognitoUserPoolClient: XXXXXXXXXXXXXX
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:*
        - s3:*
        - ses:*
      Resource: '*'

plugins:
  - serverless-s3-sync
  - uuid

custom:
  tableNamePost: news
  imagePostsBucket: postimagesbucket-123456

functions:
  getUser:
    handler: lambdas/endpoints/getUser.handler
    events:
      - http:
         path: get-user/{ID}
         method: GET
         cors: true
  getPost:
    handler: lambdas/endpoints/getPost.handler
    events:
      - http:
         path: get-post/{ID}
         method: GET
         cors: true
  createPost:
    handler: lambdas/endpoints/createPost.handler
    events:
      - http:
         path: create-post
         method: POST
         cors: true
  uploadImage:
    handler: lambdas/endpoints/uploadImage.handler
    events:
      - http:
         path: upload-image
         method: POST
         cors: true
  likePost:
    handler: lambdas/endpoints/likePost.handler
    events:
      - http:
         path: like-post/{ID}
         method: PUT
         cors: true
  userSignUp:
    handler: lambdas/endpoints/userSignUp.handler
    events:
      - http:
         path: sign-up
         method: POST
         cors: true
  confirmSignUp:
    handler: lambdas/endpoints/confirmSignUp.handler
    events:
      - http:
         path: confirm-signUp
         method: POST
         cors: true
  userSignIn:
    handler: lambdas/endpoints/userSignIn.handler
    events:
      - http:
         path: sign-in
         method: POST
         cors: true

resources:
  Resources:
    ImagesPostBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.imagePostsBucket}
    MyDynamoDBTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:custom.tableNamePost}
        AttributeDefinitions:
          - AttributeName: ID
            AttributeType: S
        KeySchema:
          - AttributeName: ID
            KeyType: HASH
        BillingMode: PAY_PER_REQUEST
    CognitoUserPool:
      Type: AWS::Cognito::UserPool
      Properties:
        UserPoolName: ${self:provider.stage}-user-pool
        UsernameAttributes:
          - email
        AutoVerifiedAttributes:
          - email
        Policies:
          PasswordPolicy:
            MinimumLength: 6
            RequireLowercase: False
            RequireNumbers: True
            RequireSymbols: False
            RequireUppercase: True
    CognitoUserPoolClient:
      Type: AWS::Cognito::UserPoolClient
      Properties:
        ClientName: ${self:provider.stage}-user-pool-client
        UserPoolId:
          Ref: CognitoUserPool
        ExplicitAuthFlows:
          - ADMIN_NO_SRP_AUTH
        GenerateSecret: false
EN

回答 3

Stack Overflow用户

发布于 2021-02-23 01:23:17

我建议删除该插件,然后再试一次。如果你需要这个插件,你可能需要打开一个bug ticket in the repo here

票数 0
EN

Stack Overflow用户

发布于 2021-02-23 02:56:44

似乎缺少serverless-s3-sync的配置请检查serverless-s3-sync插件的文档以及如何对其进行SETUP

代码语言:javascript
复制
custom:
  s3Sync:
    # A simple configuration for copying static assets
    - bucketName: my-static-site-assets # required
      bucketPrefix: assets/ # optional
      localDir: dist/assets # required

resources:
  Resources:
    AssetsBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-static-site-assets
票数 0
EN

Stack Overflow用户

发布于 2022-01-11 07:38:55

请参考此处的解决方案:https://githubmate.com/repo/ar90n/serverless-s3-local/issues/294

在sls和节点无服务器插件(在我的例子中是无服务器的wsgi)之间有一个依赖版本模拟匹配。我已经有一年没有使用我的sls了,所以它已经过时了。

我不得不用:curl -o- -L https://slss.io/install | bash重新安装sls

https://www.serverless.com/framework/docs/getting-started#install-as-a-standalone-binary

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66319917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档