npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm init failing to prompt or output package.json

npm init is failing to prompt or output package.json! It executes and gives me the shell prompt again without any failure message, and without actually prompting.

os: macOS Catalina
node version: 12.12.0
npm version: 6.12.0

I’ve re-installed npm and no change

$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and save it as a dependency in the package.json file.

Press ^C at any time to quit.

$ <prompt>

Hi @tarcher! Odd.

What is the folder name where you are running the command? (There have been some problems reported when the folder name is not a valid package name, but they have showed an error so may not be that…)

What does npm init -y do?

Yes, it is odd. In my years of using npm I’ve never seen this before.

Folder doesn’t matter, but for the sake of argument I tried this one:

npm init -y returns a blank line, then the shell again. No file is created.

In addition I’ve stepped through the npm code itself and promzard which is used for prompting is never firing a “data” event!

I stepped through the code and the code in question is in init-package-json.js. The promzard code starts at line 69.