npm/init-package-json

[BUG] npm init not working - throws error

Closed this issue · 4 comments

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When running npm init, i receive a generic error. I've tried different folders, but it makes no difference. It seems to work fine with yarn. I've tried running different versions of Node and Npm. I've tried with or without NVM, but the same error occurs on Sonoma.

image

Expected Behavior

I expect no error, and to be walked through the npm init tutorial.

Steps To Reproduce

  1. open terminal and change directory to a new project folder
  2. run npm init or npm init -y
  3. ---> see error

Environment

  • npm: 10.2.4
  • Node: 20.11.1
  • OS: Mac OS Sonoma 14.2.1
  • platform: Macbook Pro

Attached is the error log file.

2024-01-17T03_07_33_691Z-debug-0.log

To add, upon creating a blank package.json file manually and attempt to run npm init. I encounter another error:

Screenshot 2024-01-16 at 10 14 34 PM

2024-01-17T03_14_22_540Z-debug-0.log

I can't reproduce this. The log seems to indicate that you are typing npm run init not npm init. The error missing script: init also indicates this.

This is not an npm bug, it appears you have some sort of os alias or config that is doing this.

@wraithgar you're correct. It seems like an old script snuck into my .zshrc: alias npm='npm run '

Thank you!