DylanAllen / noiiice

a serverless blog built on NuxtJS, AWS, serverless framework, and irrational exuberance.
https://noiiice.com
MIT License
45 stars 7 forks source link

"sls deploy --stage dev" stops with a Type Error #4

Closed airpaio closed 5 years ago

airpaio commented 5 years ago

I am struggling to get this blog framework up and running properly.

This appears that it may be an upstream issue, however I wanted to see if you have faced any similar problem running sls deploy --stage dev

The CloudFormation stack is in a COMPLETE state, however my S3 media bucket ends up being empty. I have included the command output below that show a Type Error in the serverless framework. Have you faced this issue? I'm curious which versions of node and serverless you have this working on? I am trying this with

$ node -v
v10.16.3

$ sls -v
Framework Core: 1.53.0
Plugin: 3.1.0
SDK: 2.1.1
Components Core: 1.1.1
Components CLI: 1.2.3
...
Serverless: Pulling CF Outputs
Serverless: Checking for API key in Admin user attributes
Serverless: Creating Admin API Key

  Type Error ---------------------------------------------

  TypeError: that.sdk[service] is not a constructor
      at persistentRequest (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\provider\awsProvider.js:287:28)
      at doCall (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\provider\awsProvider.js:238:11)
      at BbPromise (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\provider\awsProvider.js:261:16)
      at Promise._execute (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\debuggability.js:313:9)
      at Promise._resolveFromExecutor (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:488:18)
      at new Promise (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:79:10)
      at persistentRequest (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\provider\awsProvider.js:236:7)
      at Object.request.requestQueue.add [as promiseGenerator] (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\provider\awsProvider.js:283:7)
      at Queue._dequeue (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\promise-queue\lib\index.js:153:30)
      at C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\promise-queue\lib\index.js:109:18
      at Promise._execute (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\debuggability.js:313:9)
      at Promise._resolveFromExecutor (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:488:18)
      at new Promise (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:79:10)
      at Queue.add (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\promise-queue\lib\index.js:94:16)
      at AwsProvider.request (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\provider\awsProvider.js:282:39)
      at module.exports (E:\airpa\noiiice\.serverless_plugins\noiiice-plugin\createAdminAPIKey.js:73:33)

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

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              10.16.3
     Framework Version:         1.53.0
     Plugin Version:            3.1.0
     SDK Version:               2.1.1
     Components Core Version:   1.1.1
     Components CLI Version:    1.2.3
DylanAllen commented 5 years ago

I found the bug that is causing this, and pushed updates to the master branch to fix. Pull those updates down, and then you can re-run sls deploy --stage dev again or you can run the following commands to avoid an entire re-deploy:

sls postDeployActions --stage dev sls buildNuxtApp --stage dev

The first command should complete pretty quickly, the second command will build the Nuxt app and re-deploy to the lambda function.

airpaio commented 5 years ago

Got a little farther this time. Now it breaks with a credentials error when running sls buildNuxtApp --stage dev

I did try aws s3 cp filename s3://mediabucketname and it worked fine, so I'm assuming I have my credentials set up correctly. They are in .aws/credentials.

Serverless: Building and deploying Noiiice ...
Apps Found:  [ 'apps/app' ]

  Credentials Error --------------------------------------

  CredentialsError: Missing credentials in config
      at RemoteCredentials.getECSFullUri (E:\airpa\noiiice\node_modules\aws-sdk\lib\credentials\remote_credentials.js:99:11)
      at RemoteCredentials.load (E:\airpa\noiiice\node_modules\aws-sdk\lib\credentials\remote_credentials.js:183:22)
      at RemoteCredentials.coalesceRefresh (E:\airpa\noiiice\node_modules\aws-sdk\lib\credentials.js:205:12)
      at RemoteCredentials.refresh (E:\airpa\noiiice\node_modules\aws-sdk\lib\credentials\remote_credentials.js:172:10)
      at RemoteCredentials.get (E:\airpa\noiiice\node_modules\aws-sdk\lib\credentials.js:122:12)
      at getAsyncCredentials (E:\airpa\noiiice\node_modules\aws-sdk\lib\config.js:361:24)
      at Config.getCredentials (E:\airpa\noiiice\node_modules\aws-sdk\lib\config.js:381:9)
      at Request.VALIDATE_CREDENTIALS (E:\airpa\noiiice\node_modules\aws-sdk\lib\event_listeners.js:81:26)
      at Request.callListeners (E:\airpa\noiiice\node_modules\aws-sdk\lib\sequential_executor.js:102:18)
      at Request.emit (E:\airpa\noiiice\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
      at Request.emit (E:\airpa\noiiice\node_modules\aws-sdk\lib\request.js:683:14)
      at Request.transition (E:\airpa\noiiice\node_modules\aws-sdk\lib\request.js:22:10)
      at AcceptorStateMachine.runTo (E:\airpa\noiiice\node_modules\aws-sdk\lib\state_machine.js:14:12)
      at Request.runTo (E:\airpa\noiiice\node_modules\aws-sdk\lib\request.js:403:15)
      at E:\airpa\noiiice\node_modules\aws-sdk\lib\request.js:792:12
      at new Promise (<anonymous>)
      at Request.promise (E:\airpa\noiiice\node_modules\aws-sdk\lib\request.js:778:12)
      at loadCfOutput (E:\airpa\noiiice\.serverless_plugins\build-apps\index.js:56:70)
      at TaleBuildApps.doWork (E:\airpa\noiiice\.serverless_plugins\build-apps\index.js:176:11)
      at BbPromise.reduce (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:505:55)
      at tryCatcher (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\util.js:16:23)
      at Object.gotValue (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\reduce.js:157:18)
      at Object.gotAccum (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\reduce.js:144:25)
      at Object.tryCatcher (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\util.js:16:23)
      at Promise._settlePromiseFromHandler (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:517:31)
      at Promise._settlePromise (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:574:18)
      at Promise._settlePromiseCtx (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promise.js:611:10)
      at _drainQueueStep (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:142:12)
      at _drainQueue (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:131:9)
      at Async._drainQueues (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:147:5)
      at Immediate.Async.drainQueues (C:\Users\crobi\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\async.js:17:14)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)
      at process.topLevelDomainCallback (domain.js:126:23)

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

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              10.16.3
     Framework Version:         1.53.0
     Plugin Version:            3.1.0
     SDK Version:               2.1.1
     Components Core Version:   1.1.1
     Components CLI Version:    1.2.3
DylanAllen commented 5 years ago

I had not finished refactoring the way that plugin uses the AWS sdk (I had for the other plugin). So now it is updated as well, and you should not have that issue. Pull down the recent update and try sls buildNuxtApp --stage dev again. It should use the same profile that the Serverless framework is using for deployment.

Also, thank you for working through this! This is obviously very new, but it has a lot of potential. I really want it to be great, but I still have some work to do and I need other devs to test it out and let me know what does and doesn't work for them.

airpaio commented 5 years ago

Got a little close this time...

This time sls buildNuxtApp --stage dev removed the apps/app/node-modules/ and then re-installed them. Originally I had just npm installed apps/app/node-modules. That makes me wonder if something in the serverless process is needed as a dependency to run the app locally like the issue I'm having in #5?

Anyways, here is where it got hung up this time:

Serverless: Noiice Nuxt: Building ...
'export' is not recognized as an internal or external command,
operable program or batch file.

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

  Error: Command failed: export stage=dev
      at checkExecSyncError (child_process.js:629:11)
      at execSync (child_process.js:666:13)
      at runAppCmd (E:\airpa\noiiice\.serverless_plugins\build-apps\index.js:69:5)
      at nuxtBuild (E:\airpa\noiiice\.serverless_plugins\build-apps\index.js:91:9)
      at buildApps (E:\airpa\noiiice\.serverless_plugins\build-apps\index.js:101:9)
      at TaleBuildApps.doWork (E:\airpa\noiiice\.serverless_plugins\build-apps\index.js:155:5)

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

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              10.16.3
     Framework Version:         1.53.0
     Plugin Version:            3.1.0
     SDK Version:               2.1.1
     Components Core Version:   1.1.1
     Components CLI Version:    1.2.3
DylanAllen commented 5 years ago

Fixed. Pull down the master branch and try again.

There is a different syntax for exporting environment variables in windows Command Prompt than there is for Mac (EXPORT vs SET), I added a check for that so it will pick the correct command.

airpaio commented 5 years ago

Cool! Finally got to the end of the process without throwing any errors. However, it didnt seem to move any files into my S3 mediaBucket that I defined. Somewhere along the way it should have thrown the files from apps/app/ into the S3 mediaBucket, right?

DylanAllen commented 5 years ago

Great! The app is served from a lambda function. That media bucket is for images that you upload through the admin ui after deployment, so there should not be anything in it yet.