Skip to content
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

Error EPERM: operation not permitted, version 1.1.9 #170

Open
sofyan-ahmad opened this issue Jul 17, 2019 · 58 comments · May be fixed by #212
Open

Error EPERM: operation not permitted, version 1.1.9 #170

sofyan-ahmad opened this issue Jul 17, 2019 · 58 comments · May be fixed by #212

Comments

@sofyan-ahmad
Copy link

sofyan-ahmad commented Jul 17, 2019

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

@JackCuthbert
Copy link
Contributor

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?

@up4
Copy link

up4 commented Jul 24, 2019

I have the same problem, on macOS as well.

Appending debug log here.

`SLS_DEBUG=* npx sls deploy --stage prod -v
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Compiling with Typescript...
Serverless: Using local tsconfig.json
Serverless: Typescript compiled.

Error --------------------------------------------------

EPERM: operation not permitted, unlink '/Users/up4/api/.build/node_modules'

 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Stack Trace --------------------------------------------

Error: EPERM: operation not permitted, unlink '/Users/up4/api/.build/node_modules'
at Object.unlinkSync (fs.js:976:3)
at TypeScriptPlugin. (/Users/up4/api/node_modules/serverless-plugin-typescript/src/index.ts:195:12)
at Generator.next ()
at /Users/up4/api/node_modules/serverless-plugin-typescript/dist/src/index.js:7:71
at new Promise ()
at __awaiter (/Users/up4/api/node_modules/serverless-plugin-typescript/dist/src/index.js:3:12)
at TypeScriptPlugin.copyDependencies (/Users/up4/api/node_modules/serverless-plugin-typescript/dist/src/index.js:166:16)
at TypeScriptPlugin. (/Users/up4/api/node_modules/serverless-plugin-typescript/src/index.ts:45:20)
at Generator.next ()
at fulfilled (/Users/up4/api/node_modules/serverless-plugin-typescript/dist/src/index.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
From previous event:
at PluginManager.invoke (/Users/up4/api/node_modules/serverless/lib/classes/PluginManager.js:464:22)
at PluginManager.spawn (/Users/up4/api/node_modules/serverless/lib/classes/PluginManager.js:484:17)
at Deploy. (/Users/up4/api/node_modules/serverless/lib/plugins/deploy/deploy.js:115:50)
From previous event:
at Object.before:deploy:deploy [as hook] (/Users/up4/api/node_modules/serverless/lib/plugins/deploy/deploy.js:100:30)
at /Users/up4/api/node_modules/serverless/lib/classes/PluginManager.js:464:55
From previous event:
at PluginManager.invoke (/Users/up4/api/node_modules/serverless/lib/classes/PluginManager.js:464:22)
at PluginManager.run (/Users/up4/api/node_modules/serverless/lib/classes/PluginManager.js:496:17)
at /Users/up4/api/node_modules/serverless/lib/Serverless.js:116:33
at processImmediate (internal/timers.js:439:21)
at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
at Serverless.run (/Users/up4/api/node_modules/serverless/lib/Serverless.js:103:74)
at /Users/up4/api/node_modules/serverless/bin/serverless.js:52:28
at /Users/up4/api/node_modules/graceful-fs/graceful-fs.js:111:16
at /Users/up4/api/node_modules/graceful-fs/graceful-fs.js:45:10
at FSReqCallback.oncomplete (fs.js:153:23)
From previous event:
at /Users/up4/api/node_modules/serverless/bin/serverless.js:52:6
at processImmediate (internal/timers.js:439:21)
at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
at Object. (/Users/up4/api/node_modules/serverless/bin/serverless.js:38:39)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
at /usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com

Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.6.0
Serverless Version: 1.48.3
Enterprise Plugin Version: 1.3.2
Platform SDK Version: 2.1.0`

@up4
Copy link

up4 commented Jul 24, 2019

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

@ThomasEg
Copy link

ThomasEg commented Aug 8, 2019

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

@ThomasEg
Copy link

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...

@JackCuthbert
Copy link
Contributor

@ThomasEg I tend to agree, I've had a heap of issues getting symlink code to work across *nix and Windows. Windows doesn't allow symlinks without administrator level permissions (ref) and there are already a heap of flaky workarounds for exactly that problem (likely causing this issue).

Making matters worse is the fact that this plugin tries to support webpack configurations which change the expected output directory/file on top of TypeScript ones (aside: why do people feel they need to use this plugin in addition to webpack + ts-loader or similar?), I'm beginning to think that the scope of this plugin is far too large to be reasonably maintainable for just one person. Perhaps @divyenduz can weigh in here?

@ThomasEg
Copy link

ThomasEg commented Aug 14, 2019

@JackCuthbert why do people feel they need to use this plugin in addition to webpack + ts-loader or similar?

I have, multiple times, tried to move away from this plugin to webpack, due to issues like this one... but i cannot get a satisfying result. Either i drown in strange runtime-errors i cannot track down or huuuuuuge compiletime...

@andrewoh531
Copy link

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.

@grigorecezar
Copy link

Same issue here. Downgrading to v1.1.7 worked...

@smprime
Copy link

smprime commented Aug 31, 2019

folder permissions issue when building:

$ sudo rm -rf .build/

@dcworldwide
Copy link

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.

@creduo
Copy link

creduo commented Sep 14, 2019

Downgraded to 1.1.7 too, working fine

@vicary
Copy link

vicary commented Sep 16, 2019

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.

@justinlazaro-iselect
Copy link

@vicary still having an issue

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

fixing when downgraded to v1.1.7

@kylemh
Copy link

kylemh commented Oct 16, 2019

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

@AranDekar
Copy link

downgrading to 1.1.7 worked for me, deleting .build and .serverless didn't help

@kylemh
Copy link

kylemh commented Oct 18, 2019

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

@fsproru
Copy link

fsproru commented Nov 10, 2019

Getting the same error, deleting .build and .serverless doesn't help. Any suggestions?

@fsproru
Copy link

fsproru commented Nov 22, 2019

We had a similar issue in serveless-localstack repo which has a fix: localstack/serverless-localstack#34

@walterdl
Copy link

walterdl commented Dec 8, 2019

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.

@shierro
Copy link

shierro commented Dec 12, 2019

same w/ me. i have a local file linked to the app via package.json. reverting to 1.1.7 worked. i'm on a windows machine

Versions
serverless cli: 1.59.3
typscript: 3.4.5

@chanmathew
Copy link

Getting this issue as well.

serverless-plugin-typescript 1.1.9
Typescript 3.7.3
Serverless CLI 1.59.3

@pvsvamsi
Copy link

pvsvamsi commented Jan 8, 2020

My serverless-plugin-typescript version is 1.1.9
I got this issue, after changing my branches which are having different dependencies.
Removed the .build folder and re run.
Then it started working without any issue.
So, I recommend everyone to first try deleting the .build folder, before downgrading to 1.1.7

@KingDarBoja
Copy link

KingDarBoja commented Jan 11, 2020

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.

@KingDarBoja
Copy link

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!

@u1810291
Copy link

u1810291 commented Feb 22, 2021

Running this command was my mistake.

npm config set prefix /usr/local

Path /usr/local is not for windows. This command changed the prefix variable at 'C:\Program Files (x86)\Git\local'

To access and make a change to this directory I need to run my cmd as administrator.

So I did:

   Run cmd as administrator
   Run npm config edit (You will get notepad editor)
   Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
   Then npm start works in a normal console.

@MatteoGioioso
Copy link

same bug here

@D-Pagey
Copy link

D-Pagey commented Jun 3, 2021

Deleting .build then running sls deploy worked for me

@Arquetipo28
Copy link

@D-Pagey solution worked for me

@ashawley
Copy link

There is a possible fix proposed in #212, but it's complicated by the fact there are other issues that need changes around the same lines in the code, for example see #181 and #224.

@runna-app
Copy link

Still getting this issue on 2.1.0

@runna-app
Copy link

version 2.1.0 of serverless-plugin-typescript

@D-Pagey
Copy link

D-Pagey commented Nov 2, 2021

Deleting .build then running sls deploy worked for me

Came back months later when upgrading to runtime: nodejs14.x for optional chaining. The above worked again 👍

@markcastle
Copy link

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

@raiseandfall
Copy link

raiseandfall commented Jan 3, 2022

Still happening with 2.1.0, I tried everything above as well as switching between node versions, still no luck unless you downgrade to 1.1.7.

@joaogameprog
Copy link

@raiseandfall
Looking at the plugin's code I've discovered what seems to be happening.
fs.unlinkSync() is used to remove only files, NOT folders (node_modules).

More details:
#219 (comment)

@ashawley
Copy link

ashawley commented Jan 6, 2022

The proposed PR #212 suggests just using removeSync, would that not be sufficient?

joaogameprog pushed a commit to joaogameprog/serverless-plugin-typescript that referenced this issue Jan 7, 2022
… remove node_modules when packaging serverless project
@lucaspiller
Copy link

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

@kim00425
Copy link

i have same issue

@victebrito
Copy link

Still getting this issue with 2.1.1 of serverless-plugin-typescript and serverless 2.72.3.
Downgrading to 1.1.7 worked as mentioned.

@davidboom95
Copy link

Same issue here.

@sdasun
Copy link

sdasun commented Apr 18, 2022

I migrated to next.js just to solve this issue, but I do not regret it :D

@kubk
Copy link

kubk commented Apr 30, 2022

Also getting the issue with newest ^2.1.2 of serverless-plugin-typescript
Seems like removing .build fixes the issue

@kobayashiharuto
Copy link

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/**'

@joneteus
Copy link

I have the same issue. Only thing that makes newer versions to work is to comment out package section in serverless.yaml

@httpiga
Copy link

httpiga commented May 20, 2022

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.

@jamsmd
Copy link

jamsmd commented Jun 10, 2022

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

@brduarte
Copy link

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/**'

This worked for me.

@JulienRioux
Copy link

Downgrading to 1.1.7 was the only solution that worked for me

@adamjq
Copy link

adamjq commented Oct 2, 2022

@httpiga's solution worked for me with 2.1.2

@gimantha23
Copy link

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

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