aws-amplify / aws-amplify/amplify-cli

Error when running Amplify 8.x from VSCode debugger

Open
#10,284 34 comments 1 reaction 0 assignees View on GitHub
bug p2 platform
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

v16.14.0

### Amplify CLI Version

8.0.2

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

Didn't get there yet

### Amplify Categories

Not applicable

### Amplify Commands

configure

### Describe the bug

I just installed the cli with: `npm i -g @aws-amplify/cli` from VSCode terminal.
It was not working and I also tried to downgrade from 8.0.2 to 8.0.0: `npm install -g @aws-amplify/cli@8.0.0`

With both times it would throw the same error when running any amplify command:

> internal/modules/package_json_reader.js:4
const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
> ^
>
> TypeError: require(...).internalModuleReadJSON is not a function
> at internalModuleReadJSON (internal/modules/package_json_reader.js:4:68)
> at Object.read (internal/modules/package_json_reader.js:21:34)
> at readPackage (internal/modules/cjs/loader.js:264:36)
> at readPackageScope (internal/modules/cjs/loader.js:297:19)
> at trySelf (internal/modules/cjs/loader.js:412:40)
> at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:24)
> at Function.Module._load (internal/modules/cjs/loader.js:746:27)
> at Module.require (internal/modules/cjs/loader.js:974:19)
> at Module._preloadModules (internal/modules/cjs/loader.js:1244:12)
> at loadPreloadModules (internal/bootstrap/pre_execution.js:480:5)

When I run `amplify` from the Mac terminal it works. It's weird because `sam` and `aws` work just fine from both terminals.

### Expected behavior

to work

### Reproduction steps

1. npm install -g @aws-amplify/cli@8.0.0
2. amplify configure

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `npm install -g @aws-amplify/cli@8.0.0` followed by `amplify configure` in the VSCode terminal and compare it with the Mac terminal, where it works. Inspect the Node.js runtime and preload environment used by each terminal; done means Amplify commands run successfully in VSCode without the `internalModuleReadJSON` error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, vscode
Domain
cli, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.