Skip to content

Bug: sam local invoke -d option now working with nodejs16.x #3886

@deepak-panwar-paf

Description

@deepak-panwar-paf

Description:

sam local invoke -d 5858 -e is failing for nodejs16.x it working fine in nodejs14.x

Steps to reproduce:

create nodejs16.x Hello World Example project project from sam init command
run command sam local invoke -d 5858 HelloWorldFunction -e events/event.json

inside vs code inspect using following launch configuration

{
            "name": "inspector",
            "type": "node",
            "request": "attach",
            "address": "localhost",
            "port": 5858,
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "/var/task",
            "protocol": "inspector",
            "stopOnEntry": false
        }

Observed result:

START RequestId: ff3620cf-03d2-4a3f-a204-9d4665c56dd5 Version: $LATEST
Debugger listening on ws://0.0.0.0:5858/ecdab66e-0a85-4da9-b4ec-8e0e511faeaa
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
node:internal/modules/cjs/loader:936
throw err;
^

Error: Cannot find module '/var/runtime/index.js'
at Function._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Observations

I checked in the docker image there is no such file with name index.js inside var/task folder in node16 image only index.mjs file was present. index.js file is present in node14 docker image

Expected result:

With given launch configuration you should be able to inspect in the source code instead of getting error

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
OS: Mac
sam --version: 1.50.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions