Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: 'import' and 'export' may appear only with 'sourceType: module', When running sls deploy #61

Open
basselabbara opened this issue Nov 25, 2022 · 0 comments

Comments

@basselabbara
Copy link

basselabbara commented Nov 25, 2022

Description

sls deploy only works when I remove serverless-plugin-optimize from serverless.yaml

Service configuration (serverless.yml) content

service: nest-serverless-lambda

plugins:
 - 'serverless-plugin-typescript'
 - serverless-plugin-optimize
 - serverless-offline

provider:
 name: aws
 runtime: nodejs14.x

functions:
 oa-staging-backend:
   handler: packages/backend/src/app/lambda.handler
   events:
     - http:
         method: any
         path: /{any+}

Command name and used flags

sls deploy --verbose --debug "*"

Command output

lifecycle:command:invoke:hook: [17]   > before:package:createDeploymentArtifacts
lifecycle:command:invoke:hook: [17]   < before:package:createDeploymentArtifacts
Optimize: starting engines
Optimize: nest-serverless-lambda-dev-oa-staging-backend
aws: [1] { Error: connect EHOSTDOWN 169.254.169.254:80 - Local (172.20.10.8:65007)
    at internalConnect (net.js:934:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:452:18)
    at net.js:1022:9
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
  message: 'Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1',
  errno: -64,
  code: 'CredentialsError',
  syscall: 'connect',
  address: '169.254.169.254',
  port: 80,
  time: 2022-11-25T16:30:10.671Z,
  originalError:
   { message: 'Could not load credentials from any providers',
     errno: -64,
     code: 'CredentialsError',
     syscall: 'connect',
     address: '169.254.169.254',
     port: 80,
     time: 2022-11-25T16:30:10.671Z,
     originalError:
      { message: 'EC2 Metadata roleName request returned error',
        errno: -64,
        code: 'EHOSTDOWN',
        syscall: 'connect',
        address: '169.254.169.254',
        port: 80,
        time: 2022-11-25T16:30:10.671Z,
        originalError:
         { errno: -64,
           code: 'EHOSTDOWN',
           syscall: 'connect',
           address: '169.254.169.254',
           port: 80,
           message: 'connect EHOSTDOWN 169.254.169.254:80 - Local (172.20.10.8:65007)' } } } }
lifecycle:command:invoke:hook: [17]   > before:package:createDeploymentArtifacts
lifecycle:command:invoke:hook: [1] > before:deploy:deploy

✖ Stack nest-serverless-lambda-dev failed to deploy (89s)
process: handle error
process: finalize { error:
   { [SyntaxError: 'import' and 'export' may appear only with 'sourceType: module']
     message: "'import' and 'export' may appear only with 'sourceType: module'",
     line: 1,
     column: 1,
     annotated:
      "\n/Users/bassel/oa-monorep/.build/node_modules/@nestjs/axios/node_modules/axios/index.js:1\nimport axios from './lib/axios.js';\n^\nParseError: 'import' and 'export' may appear only with 'sourceType: module'",
     stream:
      Labeled {
        _readableState:
         ReadableState {
           objectMode: true,
           highWaterMark: 16,
           buffer: BufferList { length: 0 },
           length: 0,
           pipes:
            Labeled {
              _readableState: [ReadableState],
              readable: true,
              [domain]: null,
              _events: [Object: null prototype],
              _eventsCount: 8,
              _maxListeners: undefined,
              _writableState: [WritableState],
              writable: true,
              allowHalfOpen: true,
              _options: [Object],
              _wrapOptions: [Object],
              _streams: [Array],
              length: 1,
              label: 'sort',
              [Symbol(kCapture)]: false,
              _writev: null,
              [writableHighWaterMark]: [Getter],
              [destroyed]: [Getter/Setter] },
           pipesCount: 1,
           flowing: true,
           ended: false,
           endEmitted: false,
           reading: true,
           sync: false,
           needReadable: true,
           emittedReadable: false,
           readableListening: false,
           resumeScheduled: false,
           destroyed: false,
           defaultEncoding: 'utf8',
           awaitDrain: 0,
           readingMore: false,
           decoder: null,
           encoding: null },
        readable: true,
        [domain]: null,
        _events:
         [Object: null prototype] {
           end: [ [Function], [Function], [Function], [length]: 3 ],
           finish: { [Function: bound onceWrapper] [length]: 0, [name]: 'bound onceWrapper', listener: [Function] },
           error: { [Function (anonymous)] [length]: 1, [name]: '', [arguments]: null, [caller]: null, [prototype]: [Object] },
           data: { [Function: ondata] [length]: 1, [name]: 'ondata', [prototype]: [Object] },
           _mutate: { [Function: bound onceWrapper] [length]: 0, [name]: 'bound onceWrapper', listener: [Function] } },
        _eventsCount: 5,
        _maxListeners: undefined,
        _writableState:
         WritableState {
           objectMode: true,
           highWaterMark: 16,
           finalCalled: false,
           needDrain: false,
           ending: false,
           ended: false,
           finished: false,
           destroyed: false,
           decodeStrings: true,
           defaultEncoding: 'utf8',
           length: 1,
           writing: true,
           corked: 0,
           sync: false,
           bufferProcessing: false,
           onwrite: { [Function (anonymous)] [length]: 1, [name]: '', [prototype]: [Object] },
           writecb: { [Function: nop] [length]: 0, [name]: 'nop', [prototype]: [Object] },
           writelen: 1,
           bufferedRequest: null,
           lastBufferedRequest: null,
           pendingcb: 1,
           prefinished: false,
           errorEmitted: false,
           bufferedRequestCount: 0,
           corkedRequestsFree: CorkedRequest { next: null, entry: null, finish: [Function] },
           [buffer]: [Getter] },
        writable: true,
        allowHalfOpen: true,
        _options: { objectMode: true },
        _wrapOptions: { objectMode: true },
        _streams:
         [ DestroyableTransform {
             _readableState: [ReadableState],
             readable: true,
             [domain]: null,
             _events: [Object: null prototype],
             _eventsCount: 4,
             _maxListeners: undefined,
             _writableState: [WritableState],
             writable: true,
             allowHalfOpen: true,
             _transformState: [Object],
             _destroyed: false,
             _transform: [Function],
             [Symbol(kCapture)]: false,
             _writev: null,
             [writableHighWaterMark]: [Getter],
             [destroyed]: [Getter/Setter] },
           [length]: 1 ],
        length: 1,
        label: 'syntax',
        [Symbol(kCapture)]: false,
        _writev: null,
        [writableHighWaterMark]: [Getter],
        [destroyed]: [Getter/Setter] } },
  shouldBeSync: undefined,
  telemetryData: undefined,
  shouldSendTelemetry: undefined }
Environment: darwin, node 14.19.0, framework 3.25.0, plugin 6.2.2, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
'import' and 'export' may appear only with 'sourceType: module'
auth: start with cached data: {}, expires NaN
auth: resolved data from config: {}
auth: mode: null
telemetry: payload { ciName: null,
  isTtyTerminal: true,
  cliName: 'serverless',
  command: 'deploy',
  commandOptionNames: [ 'verbose', 'debug', 'stage', 'region', [length]: 4 ],
  console: { isAuthenticated: false },
  dashboard: { userId: null, orgUid: undefined },
  firstLocalInstallationTimestamp: 1669305495,
  frameworkLocalUserId: 'cde0c610-6c10-11ed-8287-49d5a986a63d',
  installationType: 'global:npm',
  isAutoUpdateEnabled: false,
  isUsingCompose: false,
  notificationsMode: 'on',
  timestamp: 1669393812432,
  timezone: 'Asia/Beirut',
  triggeredDeprecations: [ [length]: 0 ],
  versions: { serverless: '3.25.0', '@serverless/dashboard-plugin': '6.2.2' },
  commandDurationMs: 93817,
  hasLocalCredentials: false,
  npmDependencies:
   [ '@emotion/react',
     '@emotion/server',
     '@fortawesome/fontawesome-svg-core',
     '@fortawesome/free-regular-svg-icons',
     '@fortawesome/free-solid-svg-icons',
     '@fortawesome/react-fontawesome',
     '@mantine/core',
     '@mantine/form',
     '@mantine/hooks',
     '@mantine/next',
     '@mantine/notifications',
     '@nestjs/axios',
     '@nestjs/common',
     '@nestjs/config',
     '@nestjs/core',
     '@nestjs/passport',
     '@nestjs/platform-express',
     '@prisma/client',
     'amazon-cognito-identity-js',
     'aws-amplify',
     'aws-lambda',
     'aws-serverless-express',
     'core-js',
     'jwks-rsa',
     'next',
     'passport',
     'passport-jwt',
     'react',
     'react-dom',
     'reflect-metadata',
     'regenerator-runtime',
     'rxjs',
     'tslib',
     'zod',
     '@nestjs/schematics',
     '@nestjs/swagger',
     '@nestjs/testing',
     '@nrwl/cli',
     '@nrwl/cypress',
     '@nrwl/eslint-plugin-nx',
     '@nrwl/jest',
     '@nrwl/js',
     '@nrwl/linter',
     '@nrwl/nest',
     '@nrwl/next',
     '@nrwl/node',
     '@nrwl/react',
     '@nrwl/web',
     '@nrwl/workspace',
     '@testing-library/react',
     '@types/aws-serverless-express',
     '@types/jest',
     '@types/node',
     '@types/passport-jwt',
     '@types/react',
     '@types/react-dom',
     '@typescript-eslint/eslint-plugin',
     '@typescript-eslint/parser',
     'babel-jest',
     'babel-preset-es2015',
     'class-validator',
     'cypress',
     'eslint',
     'eslint-config-next',
     'eslint-config-prettier',
     'eslint-plugin-cypress',
     'eslint-plugin-import',
     'eslint-plugin-jsx-a11y',
     'eslint-plugin-react',
     'eslint-plugin-react-hooks',
     'jest',
     'jest-environment-jsdom',
     'nx',
     'plugin',
     'prettier',
     'prisma',
     'react-test-renderer',
     'sass',
     'serverless-offline',
     'serverless-plugin-optimize',
     'serverless-plugin-typescript',
     'serverless-webpack',
     'ts-jest',
     'ts-node',
     'typescript',
     [length]: 85 ],
  config:
   { configValidationMode: 'warn',
     provider: { name: 'aws', runtime: 'nodejs14.x', stage: 'dev', region: 'us-east-1' },
     variableSources: [ [length]: 0 ],
     plugins:
      [ 'serverless-plugin-typescript', 'serverless-plugin-optimize', 'serverless-offline', 'serverless-webpack', [length]: 4 ],
     functions: [ { url: false, runtime: 'nodejs14.x', events: [ [Object], [length]: 1 ] }, [length]: 1 ],
     resources: { general: [ [length]: 0 ] },
     paramsCount: 0 },
  isConfigValid: true,
  didCreateService: false,
  commandUsage: {} }

Environment information

Framework Core: 3.25.0
Plugin: 6.2.2
SDK: 4.3.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant