【问题标题】:NPM - ENOENT syscall spawn bash (this is related to npm not being able to find a file)NPM - ENOENT 系统调用 spawn bash(这与 npm 无法找到文件有关)
【发布时间】:2022-12-02 03:06:36
【问题描述】:

Overview

I am attempting to troubleshoot why I can\'t run scripts defined in a package.json file via npm run command. Every script command returns the same error message:

npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\\Temp\\test4
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Minimal Repro Steps

I installed NodeJS 18.12.1 x64 MSI from the Node Download Page on my Windows 11 machine.

I created an empty directory (called test4 in my example here) with a single file called package.json with the following content:

{
  \"scripts\": {
    \"hello\": \"echo \'Hello World\'\"
  }
}

I opened a PowerShell window as administrator inside the same folder as the package.json file listed above.

Running npm run hello generates the error message above.

Verbose/Silly Logging Results

One troubleshooting techniques I used was to enable silly logging to log as many details as possible. The results of that command (npm run hello -ddd) are below:

Expected Behavior

I had a colleague attempt the same step and he was able to get the results I anticipated:

Things I Have Already Tried

  • Completely uninstalling NodeJs/NPM following this StackOverflow answer

  • Installing different version of NodeJS/NPM. (I tried 2/3 different versions)

  • Running npm install on my simplistic package.json file above and on a \'real\' package.json file from one of my projects. Both projects install successfully.

  • Reviewed the log file mentioned in the error message referring to the AppData folder. (It\'s the same content as the verbose error screenshot I provided above)

    标签: node.js npm


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2023-01-03
    • 1970-01-01
    • 2020-10-13
    • 1970-01-01
    • 2023-02-04
    • 2019-07-22
    • 2021-01-09
    • 2020-02-27
    相关资源
    最近更新 更多