无服务器框架,EISDIR:对目录的非法操作,请阅读

时间:2018-10-22 02:12:08

标签: serverless-framework

当我尝试使用以下方法package进行服务时:

SLS_DEBUG=* $(npm bin)/serverless package

serverless-framework给我一个错误:

  Error --------------------------------------------------

  EISDIR: illegal operation on a directory, read

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: EISDIR: illegal operation on a directory, read
    at Object.fs.readSync (fs.js:675:18)
    at tryReadSync (fs.js:540:20)
    at Object.fs.readFileSync (fs.js:583:19)
    at GoogleProvider.getAuthClient (/Users/ldu020/workspace/serverless-functions/node_modules/serverless-google-cloudfunctions/provider/googleProvider.js:72:31)
    at GoogleProvider.request (/Users/ldu020/workspace/serverless-functions/node_modules/serverless-google-cloudfunctions/provider/googleProvider.js:43:29)
    at GooglePackage.setDeploymentBucketName (/Users/ldu020/workspace/serverless-functions/node_modules/serverless-google-cloudfunctions/shared/setDeploymentBucketName.js:22:26)
From previous event:
    at Object.package:initialize [as hook] (/Users/ldu020/workspace/serverless-functions/node_modules/serverless-google-cloudfunctions/package/googlePackage.js:44:10)
    at BbPromise.reduce (/Users/ldu020/workspace/serverless-functions/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
    at PluginManager.invoke (/Users/ldu020/workspace/serverless-functions/node_modules/serverless/lib/classes/PluginManager.js:390:22)
    at PluginManager.run (/Users/ldu020/workspace/serverless-functions/node_modules/serverless/lib/classes/PluginManager.js:421:17)
    at variables.populateService.then.then (/Users/ldu020/workspace/serverless-functions/node_modules/serverless/lib/Serverless.js:157:33)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at Serverless.run (/Users/ldu020/workspace/serverless-functions/node_modules/serverless/lib/Serverless.js:144:8)
    at serverless.init.then (/Users/ldu020/workspace/serverless-functions/node_modules/serverless/bin/serverless:43:50)
    at <anonymous>

我该如何解决?谢谢。

1 个答案:

答案 0 :(得分:1)

看一下错误堆栈。出现此问题的原因是我没有为Google凭据设置环境变量。

之后,它可以工作。

☁  serverless-functions [pre-dev] ⚡  PROJECT_ID=pg-gx-e-app-700452 CREDENTIALS=/Users/ldu020/workspace/serverless-functions/.gcp/pg-gx-e-app-700452-98b46018b4ea.json $(npm bin)/sls package
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling function "createCampaign"...
Serverless: Compiling function "retrieveCampaignResult"...
Serverless: Compiling function "updateCampaign"...
Serverless: Compiling function "uploadMedia"...
Serverless: Compiling function "createGGAWCampaign"...
Serverless: Compiling function "updateGGAWCampaign"...
Serverless: Compiling function "getSpecificGGAWCampaignInsightReport"...
Serverless: Compiling function "createGGAWAdGroup"...
Serverless: Compiling function "createGGAWExpandedTextAd"...