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

Try to access wrong module directory (node_mnode_modules) #127

Open
minsung-git opened this issue Aug 27, 2021 · 2 comments
Open

Try to access wrong module directory (node_mnode_modules) #127

minsung-git opened this issue Aug 27, 2021 · 2 comments

Comments

@minsung-git
Copy link

minsung-git commented Aug 27, 2021

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
          )
@EH7AN
Copy link

EH7AN commented Sep 1, 2021

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'
}
`

@cordeirovictorhc
Copy link

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

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