serverless-plugin-typescript: Error EPERM: operation not permitted, version 1.1.9

When I tried to run ‘sls deploy’, the following error is shown:

EPERM: operation not permitted, unlink '/Users/sofyan.ahmad/Projects/project-name/.build/node_modules'

The error is gone when I reverted back to version 1.1.7

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 59
  • Comments: 58 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I am unable to reproduce this one 😞 Are you using webpack? There’s another issue surrounding webpack users at the moment which may be related.

Have you tried removing the .build and .serverless folders?

I honestly don’t think serverless-plugin-typescript is to “blame” for this. I think something in the underlying fs-package messes up symlinks…

I’ve managed to fix this error by deleting the .build/.serverless/whatever directories and node-modules-directory… that solved the issue for me…

This issue is still happening

folder permissions issue when building:

$ sudo rm -rf .build/

@vicary still having an issue

"deploy:dev": "rm -rf .build/ && sls deploy",

fixing when downgraded to v1.1.7

I am also using Prisma and @kobayashiharuto 's answer fixed the error, but it will obviously increases the bundle size. My solution was to change serverless.yml, adding

package:
  individually: true

and moving the Prisma excluded paths under every single function using Prisma:

functions: 
  function-name:
    # ...
    package:
      patterns:
        - "!node_modules/.prisma/client/libquery_engine-*"
        - "node_modules/.prisma/client/libquery_engine-rhel-*"
        - "!node_modules/prisma/libquery_engine-*"
        - "!node_modules/@prisma/engines/**"

Docs reference here. That’s less elegant but at least avoids to hit the 50MB Lambda size limit.

In my case, the cause was package.patterns in serverless.yml.

I am using prisma and was following this document as written, when an error occurred. Instead of using the patterns described in this document as is, I commented out the top two as follows, and it worked.

package:
  patterns:
    # - '!node_modules/.prisma/client/libquery_engine-*'
    # - 'node_modules/.prisma/client/libquery_engine-rhel-*'
    - '!node_modules/prisma/libquery_engine-*'
    - '!node_modules/@prisma/engines/**'

Constantly having this issue, must remove the emit directory .build before deploying.

This usually happens upon build time exceptions, user interrupts during compilation also triggers this issue.

version 2.1.0 of serverless-plugin-typescript

One year after the bug reports this keeps happening.

Deleting .build and .serverless did the trick.

I’ve noticed that this issue sometimes happens if you’ve CTRL-C killed a deploy (for whatever reason) while it’s in the middle of running. Left in an inconsistent state perhaps?

As suggested the solution for me was to delete .build and the sls deploy

HTH

Still getting this issue on 2.1.0

I recently published a new version from my forked repo on npm: @kingdarboja/serverless-plugin-typescript

Please test it as I merged several PRs from this repo in order to solve several issues, including this one.

Cheers!

Getting same error with "serverless-plugin-typescript": "^1.1.9" on my project. Using Windows 10 and Node 12.

UPDATE Maybe the fs.unlinkSync on this commit for v1.1.8 is causing the issue.

Downgrading to v1.1.7 worked whilst v1.1.8 (and v1.1.9) errored.

I noticed that with v1.1.7, running sls package will create symlinks for the .build/node_modules directory.

Using v1.1.8 (or v1.1.9) it’s no longer a symlink. Something in the v1.1.8 release broke this.

Deleting .build then running sls deploy worked for me

I had a local dependency like:

"dependencies:": {
  "myLib": "file:../myLib",
  "serverless-plugin-typescript": "^1.1.9"
}

The error EPERM: operation not permitted was present. I changed to 1.1.7 and the error was gone.

We are having to problem aswell… no WebPack and on Windows…

And reverting from 1.1.9 to 1.1.7 worked for me as well.

I mixed up npm and yarn… Removed .build .serverless and package-lock.json reinstalled node_modules and it worked after

Still getting this issue with 2.1.1 of serverless-plugin-typescript

FWIW, my issue was that I needed to delete my .build folder before running the script.

As mentioned downgrading to serverless-plugin-typescript 1.1.7 worked for me

@httpiga’s solution worked for me with 2.1.2

Downgrading to 1.1.7 was the only solution that worked for me

Same here, 1.1.9 failed on the .build directory being present. Downgraded to 1.1.7 and it worked. serverless plugins installed:

  • serverless-plugin-typescript
  • serverless-offline
  • serverless-dotenv-plugin

We had a similar issue in serveless-localstack repo which has a fix: https://github.com/localstack/serverless-localstack/issues/34

I’m getting

Error: ENOENT: no such file or directory, open '/my-project/.build/node_modules/.bin/json2yaml'

when I pin version 1.1.7

Downgraded to v1.1.7. What a miserable day for productivity this was.

Ensuring adequate permissions for local user on node-modules, .build, .serverless had not affect for me.