serverless-plugin-typescript
serverless-plugin-typescript copied to clipboard
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
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.
I have the same issue as @nathanchapman . After sls package
, .build
directory is deleted and all artifacts move to .serverless
folder. But the path mentioned in stack.json is .build/.serverless/<artifcact>
. It seems the path is relative to something
Workaround (hacky) to fix this was to NOT delete folder .build
during packaging. This duplicates artifacts in 2 places. One in .build/.serverless/<artifacts>
and another in .serverless/<artifacts>
. But it satisfies all package and deploy processes
Hi, is there a fix for it? The problem seems to be still there.
Operating System: darwin
Node Version: 14.2.0
Framework Version: 1.71.1
Plugin Version: 3.6.12
SDK Version: 2.3.0
Components Version: 2.30.10
plugins:
- serverless-webpack
- serverless-plugin-typescript
- serverless-offline
serverless-plugin-typescript: 1.1.9 (downgrade to 1.1.7) does not seem to help.
It looks like the problem is the order the following plugins are listed in:
plugins:
- serverless-webpack
- serverless-offline-sqs
- serverless-offline
- serverless-plugin-typescript
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:
- serverless-plugin-typescript
- serverless-offline
Any update on this?
Any fix for this ?
I hit this problem when I forgot to create a tsconfig.json
if that helps anyone. I wasn't using serverless-offline so that was irrelevant for me.
Found a fix for the remove the serverless-plugin-typescript plugin from plugins. The serverless-plugin-typescript doesn't work with the serverless-webpack plugin
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.
Downgrade the version of my local serverless seems to fix the issue.
Went with npm i --save-dev [email protected]
previously it was 2.2.37
That said, some of you did have the issue with older serverless versions ...
I am not using webpack, but I use serverless-plugin-typescript & serverless-offline
Hope it helps .
Just had this issue appearing again today when I updated to 2.37.0. I reverted to 2.35.0 and it fixed it.
serverless.yml plugins
plugins:
- serverless-plugin-typescript
- serverless-offline
- serverless-aws-documentation
- serverless-plugin-git-variables
- serverless-plugin-log-retention
package.json modules versions
"serverless-plugin-git-variables": "^4.0.0",
"serverless-plugin-log-retention": "^2.0.0",
"serverless": "2.35.0",
"serverless-aws-documentation": "^1.1.0",
"serverless-offline": "^6.9.0",
"serverless-plugin-typescript": "^1.1.9",
Same here. I tried with [email protected]
and [email protected]
and was fixed.
Still an issue overhere. No clue what the no such file or directory, stat .build/.serverless
means..
Having same issue here.
I am using [email protected]
, [email protected]
and [email protected]
and ran into the same issue.
serveless plugins:
plugins: [
'serverless-dotenv-plugin',
'serverless-webpack',
'serverless-webpack-prisma',
'serverless-plugin-typescript',
'serverless-offline'
],
It seems that using serverless-plugin-typescript
is unnecessary and leading to errors when also using serverless-webpack
. (mentioned in this comment)
Deleting serverless-plugin-typescript
resolved the issue for me.
new serverless plugins:
plugins: [
'serverless-dotenv-plugin',
'serverless-webpack',
'serverless-webpack-prisma',
'serverless-offline'
],
Make sure your serverless
, serverless-plugin-typescript
etc. are in devDependencies
and not in dependencies
:
"devDependencies": {
"serverless": "^3.23.0",
"serverless-offline": "^11.2.3",
"serverless-plugin-typescript": "^2.1.4",
"serverless-python-requirements": "^6.0.0",
"typescript": "^4.8.4"
}