serverless-plugin-typescript icon indicating copy to clipboard operation
serverless-plugin-typescript copied to clipboard

Error EPERM: operation not permitted, version 1.1.9

Open sofyan-ahmad opened this issue 6 years ago • 58 comments
trafficstars

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

sofyan-ahmad avatar Jul 17 '19 15:07 sofyan-ahmad

I am unable to reproduce this one :disappointed: 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?

JackCuthbert avatar Jul 21 '19 04:07 JackCuthbert

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 avatar Jul 24 '19 15:07 up4

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

up4 avatar Jul 24 '19 15:07 up4

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

ThomasEg avatar Aug 08 '19 11:08 ThomasEg

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

ThomasEg avatar Aug 12 '19 12:08 ThomasEg

@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?

JackCuthbert avatar Aug 12 '19 23:08 JackCuthbert

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

ThomasEg avatar Aug 14 '19 07:08 ThomasEg

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.

andrewoh531 avatar Aug 14 '19 11:08 andrewoh531

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

grigorecezar avatar Aug 29 '19 13:08 grigorecezar

folder permissions issue when building:

$ sudo rm -rf .build/

smprime avatar Aug 31 '19 16:08 smprime

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.

dcworldwide avatar Sep 14 '19 05:09 dcworldwide

Downgraded to 1.1.7 too, working fine

creduo avatar Sep 14 '19 05:09 creduo

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.

vicary avatar Sep 16 '19 10:09 vicary

@vicary still having an issue

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

fixing when downgraded to v1.1.7

justinlazaro-iselect avatar Sep 17 '19 03:09 justinlazaro-iselect

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

kylemh avatar Oct 16 '19 19:10 kylemh

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

AranDekar avatar Oct 18 '19 04:10 AranDekar

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

kylemh avatar Oct 18 '19 16:10 kylemh

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

fsproru avatar Nov 10 '19 06:11 fsproru

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

fsproru avatar Nov 22 '19 19:11 fsproru

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.

walterdl avatar Dec 08 '19 21:12 walterdl

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

shierro avatar Dec 12 '19 07:12 shierro

Getting this issue as well.

serverless-plugin-typescript 1.1.9 Typescript 3.7.3 Serverless CLI 1.59.3

chanmathew avatar Dec 18 '19 19:12 chanmathew

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

pvsvamsi avatar Jan 08 '20 11:01 pvsvamsi

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 avatar Jan 11 '20 18:01 KingDarBoja

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!

KingDarBoja avatar Feb 25 '20 02:02 KingDarBoja

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!

This is the only solution that worked for me, downgrade to 1.1.7 didn't work for me. (Ubuntu WSL)

sdasun avatar Apr 05 '20 21:04 sdasun

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

resinten avatar Apr 22 '20 14:04 resinten

Same issue as everyone else here:

  • Packaging worked with serverless-plugin-typescript 1.1.7, but it included devdependencies which increased my bundle size way above the 250MB limit.
  • Packaging fails with 1.1.8 with this error:
  Error: ENOENT: no such file or directory, open '[...]/.build/node_modules/[symlinked-module-name]'

Additional info: We're using Lerna for managing our packages and linking them.

ardalann avatar May 07 '20 18:05 ardalann

Check @KingDarBoja 's fork at @kingdarboja/serverless-plugin-typescript.

thiagohirata avatar Jul 20 '20 17:07 thiagohirata

One year after the bug reports this keeps happening.

Deleting .build and .serverless did the trick.

diegomarzo avatar Oct 07 '20 12:10 diegomarzo