Skip to content

Error when deploy: "no such file or directory .build/.serverless" #167

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

Open
tomzaku opened this issue Jul 17, 2019 · 17 comments
Open

Error when deploy: "no such file or directory .build/.serverless" #167

tomzaku opened this issue Jul 17, 2019 · 17 comments
Labels

Comments

@tomzaku
Copy link

tomzaku commented Jul 17, 2019

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
@nathanchapman
Copy link

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.

@rashid301
Copy link

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

@rashid301
Copy link

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

@PavelYaroshchyk
Copy link

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.

@melaku-z
Copy link

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

@amouly
Copy link

amouly commented Aug 26, 2020

Any update on this?

@kuda1992
Copy link

kuda1992 commented Oct 7, 2020

Any fix for this ?

@veloware
Copy link

veloware commented Oct 13, 2020

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.

@kuda1992
Copy link

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

@shukla2512
Copy link

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.

@GreGosPhaTos
Copy link

GreGosPhaTos commented Apr 20, 2021

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 .

@rojanawi-droople
Copy link

rojanawi-droople commented Apr 21, 2021

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",

@GeroSalas
Copy link

Same here. I tried with [email protected] and [email protected] and was fixed.

@rnnyrk
Copy link

rnnyrk commented Jul 9, 2021

Still an issue overhere. No clue what the no such file or directory, stat .build/.serverless means..

@noeleo
Copy link

noeleo commented Sep 5, 2021

Having same issue here.

@blochmat
Copy link

blochmat commented Jun 13, 2022

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'
],

@sazzy4o
Copy link
Contributor

sazzy4o commented Nov 6, 2022

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"
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests