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

Try to access wrong module directory (node_mnode_modules)

Open minsung-git opened this issue 4 years ago • 2 comments

Issue: severless-plugin-optimize try to access wrong directory "node_mnode_modules"

Symptom

Exception -----------------------------------------------
  [OperationalError: ENOENT: no such file or directory, stat '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'] {
    cause: [Error: ENOENT: no such file or directory, stat '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'] {
      errno: -2,
      code: 'ENOENT',
      syscall: 'stat',
      path: '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'
    },
    isOperational: true,
    errno: -2,
    code: 'ENOENT',
    syscall: 'stat',
    path: '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'
  }

Serverless.yaml

custom:
  optimize:
    external: ['swagger-ui-dist']

Fix

Below fix works well in my computer. Could you follow up this issue?

Original code:

const externalDir = externalEntry.substring(
            this.serverless.config.servicePath.length,
            externalEntry.lastIndexOf('node_modules/' + external)
          ) + 'node_modules/' + external

Fixed code

const externalDir = externalEntry.substring(
            externalEntry.lastIndexOf('node_modules/' + external),
            externalEntry.indexOf(external) + external.length
          )

minsung-git avatar Aug 27 '21 07:08 minsung-git

Hi @minsung-git same problem here.

Packages:

"serverless-plugin-optimize": "4.2.1-rc.1", "@nestjs/cli": "^7.6.0", "@nestjs/core": "^8.0.6", "@nestjs/common": "^8.0.6", "@nestjs/swagger": "^5.0.9"

` Exception -----------------------------------------------

[OperationalError: ENOENT: no such file or directory, stat 'F:\test-space\heymate-backend.build\F:\test-space\heymate-backend.build\node_modules\swagger-ui-dist'] { cause: [Error: ENOENT: no such file or directory, stat 'F:\test-space\heymate-backend.build\F:\test-space\heymate-backend.build\node_modules\swagger-ui-dist'] { errno: -4058, code: 'ENOENT', syscall: 'stat', path: 'F:\test-space\heymate-backend\.build\F:\test-space\heymate-backend\.build\node_modules\swagger-ui-dist' }, isOperational: true, errno: -4058, code: 'ENOENT', syscall: 'stat', path: 'F:\test-space\heymate-backend\.build\F:\test-space\heymate-backend\.build\node_modules\swagger-ui-dist' } `

EH7AN avatar Sep 01 '21 15:09 EH7AN

Issue: severless-plugin-optimize try to access wrong directory "node_mnode_modules"

Symptom

Exception -----------------------------------------------
  [OperationalError: ENOENT: no such file or directory, stat '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'] {
    cause: [Error: ENOENT: no such file or directory, stat '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'] {
      errno: -2,
      code: 'ENOENT',
      syscall: 'stat',
      path: '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'
    },
    isOperational: true,
    errno: -2,
    code: 'ENOENT',
    syscall: 'stat',
    path: '/Users/kmin/Documents/001_delivery_2021/999/development/floaws/.build/node_mnode_modules/swagger-ui-dist'
  }

Serverless.yaml

custom:
  optimize:
    external: ['swagger-ui-dist']

Fix

Below fix works well in my computer. Could you follow up this issue?

Original code:

const externalDir = externalEntry.substring(
            this.serverless.config.servicePath.length,
            externalEntry.lastIndexOf('node_modules/' + external)
          ) + 'node_modules/' + external

Fixed code

const externalDir = externalEntry.substring(
            externalEntry.lastIndexOf('node_modules/' + external),
            externalEntry.indexOf(external) + external.length
          )

same issue and this worked for me! thks

cordeirovictorhc avatar Mar 31 '22 16:03 cordeirovictorhc