For bug reports:
offline: Failure: Cannot find module '/Users/nader/Projects/company/4m-bamboohr-xero-integration/.build/.webpack/service/src/functions/approved-leaves/getTimeOffRequests'
offline: Failure: Cannot find module '/Users/nader/Projects/company/4m-bamboohr-xero-integration/.webpack/service/src/functions/approved-leaves/getTimeOffRequests'
mode: isLocal ? 'development' : 'production',
entry: slsw.lib.entries,
devtool: isLocal ? 'cheap-module-eval-source-map' : 'source-map',
resolve: {
extensions: ['.mjs', '.json', '.ts'],
symlinks: false,
cacheWithContext: false,
},
output: {
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
tsconfig
"compilerOptions": {
"lib": ["es2017"],
"module": "commonjs",
"removeComments": true,
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"target": "es2017",
"outDir": ".build",
"sourceRoot": "/",
"rootDir": "./src"
},
Similar or dependent issue(s):
How is your serverless.yml config? How to do you launch serverless offline?
the serverless.yml
service:
name: service-4m-bamboohr-xero
# app and org for use with dashboard.serverless.com
app: bamboohr-xero-integration
# org: company
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'dev'}
region: ap-southeast-2
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:BatchWriteItem
Resource: 'arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:custom.dynamodb.employeeTable}'
- Effect: Allow
Action:
- ssm:PutParameter
- ssm:GetParameters
- ssm:GetParameter
- ssm:GetParametersByPath
Resource:
- 'arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter/4m/*'
- 'arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter/${self:provider.stage}/*'
- Effect: Allow
Action:
- sqs:SendMessage
Resource: 'arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:${self:custom.sqsQueue.getRatesQueue}'
environment:
DYNAMODB_EMPLOYEE_TABLE: ${self:custom.dynamodb.employeeTable}
DYNAMODB_LEAVE_TABLE: ${self:custom.dynamodb.leaveTable}
SSM_OAUTH_PATH: /${self:provider.stage}/${self:app}/oauth/
SSM_BAMBOOHR_PATH: /${self:provider.stage}/${self:app}/bamboohr/
SSM_XERO_PATH: /${self:provider.stage}/${self:app}/xero/
REGION: '#{AWS::Region}'
ACCOUNT_ID: '#{AWS::AccountId}'
SQS_GETRATES_QUEUE: ${self:custom.sqsQueue.getRatesQueue}
SQS_LEAVE_QUEUE: ${self:custom.sqsQueue.getRatesQueue}
NAMESPACE: ${self:app}
ENVIRONMENT: ${self:provider.stage}
functions:
saveEmployees:
handler: src/functions/map-employees/saveEmployees.saveEmployees
events:
- http:
method: post
path: employees
cors: true
integration: 'lambda'
# request:
# schema:
# application/json: ${file(src/schema/create_employees.json)}
getEmployees:
handler: src/functions/map-employees/getEmployees.getEmployees
events:
- http:
method: get
path: employees
cors: true
enqueueEmployees:
handler: src/functions/enqueueEmployees.enqueueEmployees
events:
- http:
method: get
path: enqueueEmployees
cors: true
getTimeOffRequests:
handler: src/functions/approved-leaves/getTimeOffRequests.getTimeOffRequests
events:
- http:
method: get
path: leaves
cors: true
getXeroEmployees:
handler: ./src/functions/xero/getXeroEmployees.getXeroEmployees
events:
- http:
method: get
path: xero/employees
cors: true
getBamboohrEmployees:
handler: src/functions/bamboohr/getBamboohrEmployees.getBamboohrEmployees
events:
- http:
method: get
path: bamboohr/employees
cors: true
updateXeroEmployeeRate:
handler: src/functions/xero/updateXeroEmployeeRate.updateXeroEmployeeRate
events:
- sqs:
arn:
Fn::GetAtt:
- GetRatesQueue
- Arn
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
- serverless-plugin-typescript
- serverless-plugin-optimize
- serverless-pseudo-parameters
- serverless-dynamodb-local
- serverless-offline-ssm
- serverless-offline
custom:
dynamodb:
employeeTable: ${self:service}-tblEmployee-${self:provider.stage}
leaveTable: ${self:service}-tblLeave-${self:provider.stage}
migrate: true
# creates tables from serverless config
seed: true
#determines which data to onload
stages: ${self:provider.stage}
serverless-offline-ssm:
stages: ${self:provider.stage}
sqsQueue:
getRatesQueue: ${self:service}-getRatesQueue-${self:provider.stage}
leaveQueue: ${self:service}-leaveQueue-${self:provider.stage}
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
packager: npm
stage: ${opt:stage, self:provider.stage}
resources:
- ${file(resources/dynamo-db.yml)}
- ${file(resources/sqs.yml)}
package:
exclude:
- node_modules/**/*
include:
- src/functions/*
excludeDevDependencies: false
the run
sls offline start
I have the exact same issue. For some reason when I run serverless offline start I get two folders .build and .webpack in root directory instead of .build/.webpack.
@nitronaj I fixed this by removing serverless-plugin-typescript and leaving serverless-webpack alone. If you think of it you don't need both because you compile the code with webpack. So when you are using both these plugins typescript code is compiled by both and there is some mess created.
@nitronaj I fixed this by removing
serverless-plugin-typescriptand leavingserverless-webpackalone. If you think of it you don't need both because you compile the code with webpack. So when you are using both these plugins typescript code is compiled by both and there is some mess created.
Thanks a lot!!
Thanks @LukaszKuciel took me waaay too long to find this thread
Most helpful comment
@nitronaj I fixed this by removing
serverless-plugin-typescriptand leavingserverless-webpackalone. If you think of it you don't need both because you compile the code with webpack. So when you are using both these plugins typescript code is compiled by both and there is some mess created.