serverless-plugin-typescript: Error when deploy: "no such file or directory .build/.serverless"
serverless.yml
plugins:
- serverless-webpack
- serverless-offline-sqs
- serverless-offline
- serverless-plugin-typescript
...
custom:
serverless-offline-sqs:
endpoint: http://localhost:4576
region: ap-southeast-2
functions:
goalUpdateHandler:
handler: src/handler.handleGoalUpdate
reservedConcurrency: 1
events:
- sqs:
queueName: GoalNotificationQueue
arn:
Fn::GetAtt:
- GoalNotificationQueue
- Arn
batchSize: 1
...
webpack.config.js
const slsw = require("serverless-webpack");
const babelOptions = {
plugins: [
"transform-runtime",
"dynamic-import-node"
],
presets: [
"es2015",
"stage-0"
]
};
module.exports = {
entry: slsw.lib.entries,
target: "node",
mode: "development",
// Generate sourcemaps for proper error messages
devtool: "source-map",
// Since 'aws-sdk' is not compatible with webpack,
// we exclude all node dependencies
// externals: [nodeExternals({ modulesDir: "../node_modules" })],
resolve: {
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
},
// Run babel on all .js files and skip those in node_modules
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: babelOptions
},
{
loader: require.resolve("ts-loader"),
options: {
happyPackMode: true,
// configFile: "../tsconfig.json",
// disable type checker - we will use it in fork plugin
transpileOnly: true
}
}
]
},
{
test: /\.js$/,
use: [
{
loader: "babel-loader",
options: babelOptions,
}
],
exclude: /node_modules/
}
]
}
};
tsconfig.json
{
"compilerOptions": {
"module": "esNext",
"target": "es2017",
"lib": [
"es2015",
"es5",
],
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": true,
"sourceMap": true,
"preserveConstEnums": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"resolveJsonModule" : true,
"typeRoots": ["./node_modules/@types", "../custom_typings", "../node_modules/@types"],
"esModuleInterop": true,
},
"exclude": [
"node_modules",
"!node_modules/@types"
]
}
Full error
Serverless: Typescript compiled.
Serverless: Packaging service...
Serverless: Remove long_path/.webpack
Error --------------------------------------------------
ENOENT: no such file or directory, stat 'long_path/.build/.serverless'
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 ---------------------------
OS: darwin
Node Version: 11.6.0
Serverless Version: 1.40.0
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 14
- Comments: 17 (1 by maintainers)
Removing the serverless-plugin-typescript works for me. Webpack can compile your typescript files using ts-loader, use that instead and remove the type-script plugin.
I have the same issue as @nathanchapman . After
sls package,.builddirectory is deleted and all artifacts move to.serverlessfolder. But the path mentioned in stack.json is.build/.serverless/<artifcact>. It seems the path is relative to somethingIt looks like the problem is the order the following plugins are listed in:
The doc states
Add the plugins to your serverless.yml file and make sure that serverless-plugin-typescript precedes serverless-offline as the order is important. The order should be changed to:Having same issue here.
I’m experiencing the same issue without a separate build plugin like webpack, babel, etc. This plugin works fine with serverless-offline, but I can’t get it to deploy.