Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Try to access wrong module directory (node_mnode_modules) #127

@minsung-git

Description

@minsung-git

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
          )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions