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

Running serverless package results in Error: EPERM: operation not permitted, unlink '..../.build/node_modules' #251

Closed
trevorgillis opened this issue Sep 13, 2021 · 5 comments

Comments

@trevorgillis
Copy link

trevorgillis commented Sep 13, 2021

Running serverless package results in the error Error: EPERM: operation not permitted, unlink '..../.build/node_modules' and I can't move forward. Here's the information about my system:

Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.17.6
Framework Version: 2.58.0 (local)
Plugin Version: 5.4.4
SDK Version: 4.3.0
Components Version: 3.17.0

Here is the output when running serverless package:

Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Compiling with Typescript...
Serverless: Using local tsconfig.json
Serverless: Typescript compiled.
 
 Error ---------------------------------------------------
 
  Error: EPERM: operation not permitted, unlink '/Users/..../.build/node_modules'
      at Object.unlinkSync (fs.js:1251:3)
      at TypeScriptPlugin.<anonymous> (/Users/..../node_modules/serverless-plugin-typescript/dist/src/index.js:176:24)
      at Generator.next (<anonymous>)
      at /Users/..../node_modules/serverless-plugin-typescript/dist/src/index.js:8:71
      at new Promise (<anonymous>)
      at __awaiter (/Users/..../node_modules/serverless-plugin-typescript/dist/src/index.js:4:12)
      at TypeScriptPlugin.copyDependencies (/Users/..../node_modules/serverless-plugin-typescript/dist/src/index.js:170:16)
      at TypeScriptPlugin.<anonymous> (/Users/..../node_modules/serverless-plugin-typescript/dist/src/index.js:46:28)
      at Generator.next (<anonymous>)
      at fulfilled (/Users/..../node_modules/serverless-plugin-typescript/dist/src/index.js:5:58)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

I am using the serverless-plugin-typescript plugin and the problem seems to stem from that. I've tried a number of different things: downgrading the plugin to 1.1.7 per this issue, deleting .serverless/, .build/, node_modules/, and yarn.lock and running yarn for a fresh start, and upgrading serverless and node, but nothing helps.

Here is my tsconfig.json file:

{
	"compilerOptions": {
		"module": "commonjs",
		"target": "es6",
		"lib": ["es6", "dom"],
		"moduleResolution": "node",
		"rootDir": "./",
		"sourceMap": true,
		"allowJs": true,
		"noImplicitAny": true,
		"noUnusedLocals": true,
		"noImplicitThis": true,
		"strictNullChecks": true,
		"noImplicitReturns": true,
		"preserveConstEnums": true,
		"suppressImplicitAnyIndexErrors": true,
		"forceConsistentCasingInFileNames": true
	},
	"exclude": ["node_modules", "build", "webpack"],
	"types": ["typePatches"]
}

And here is my serverless.yml file:

frameworkVersion: "2"

provider:
  name: aws
  runtime: nodejs14.x
  lambdaHashingVersion: ********
  profile: ***

# you can add packaging information here
package:
  patterns:
    - "!node_modules/**"
    - "node_modules/mongoose/**"
    - "node_modules/mongodb/**"
    - "node_modules/bson/**"
    - "node_modules/optional-require/**"
    - "node_modules/safe-buffer/**"
    - "node_modules/denque/**"
    - "node_modules/bl/**"
    - "node_modules/process-nextick-args/**"
    - "node_modules/isarray/**"
    - "node_modules/core-util-is/**"
    - "node_modules/inherits/**"
    - "node_modules/util-deprecate/**"
    - "node_modules/sliced/**"
    - "node_modules/ms/**"
    - "node_modules/mpath/**"
    - "node_modules/kareem/**"
    - "node_modules/mongoose-legacy-pluralize/**"
    - "node_modules/mquery/**"
    - "node_modules/regexp-clone/**"
    - "node_modules/sift/**"
    - "node_modules/saslprep/**"
    - "node_modules/readable-stream/**"
    - "node_modules/debug/**"
    - "node_modules/bluebird/**"

functions:
  devFuncName:
    handler: index.handler

plugins:
  - serverless-plugin-typescript
  - serverless-offline

configValidationMode: error

Please let me know if you need any more information from me.

@leorrodrigues
Copy link

@trevorgillis did you have any update on this problem? I'm facing the same issue

@ashawley
Copy link

I've tried a number of different things: downgrading the plugin to 1.1.7

You're using 2.0.0 version of the plugin?

@ashawley
Copy link

Actually, this is an existing bug, see #170.

@trevorgillis
Copy link
Author

@leorrodrigues I had made a mistake somewhere so that when I thought I was downgrading to v1.1.7 I wasn't actually downgrading. When I figured that out and actually downgraded to v1.1.7, the error went away, just like #170 says.

@ashawley No, I was using v1.1.9. Yes, I thought I had actually linked to #170 in the original post (that's what I had meant to do), but apparently I missed the link. I've updated the issue so that it links.

@trevorgillis
Copy link
Author

Since the downgrade to v1.1.7 worked per #170 and it was my own error for thinking that it did not originally, I'm going to close this.

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

No branches or pull requests

3 participants