The child_process in Node is attempting to utilize /usr/bin/zsh, but unfortunately, it is unable to do so because

Recently, I've been encountering issues with several npm commands failing, accompanied by an error message that looks like this:

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn /usr/bin/zsh
npm ERR! file /usr/bin/zsh
npm ERR! path /usr/bin/zsh
npm ERR! errno ENOENT
npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8c5d1f8dac7c2e89886998698">[email protected]</a> preinstall: `npm run myCommand`
npm ERR! spawn /usr/bin/zsh ENOENT
npm ERR!
npm ERR! Failed at the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d00143d1f02072d5d5d5d">[email protected]</a> preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

Upon investigation, it seems that the cause of this error is likely due to the absence of /usr/bin/zsh. In reality, zsh is located within /bin/zsh on my system.

The troublesome script responsible for triggering this error contains:

const { exec } = require('child_process');
exec('npm -v', (err, stdout) => {
  if (err) throw err;
  if (parseFloat(stdout) < 5) {
    // NOTE: This may occur if a dependency specifies an outdated version of npm in its dependencies.
    throw new Error(`[ERROR] You need npm version @>=5 but you have ${stdout}`);
  }
});

The detailed stack indicates:

17 verbose stack spawn /usr/bin/zsh ENOENT
17 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
17 verbose stack     at onErrorNT (internal/child_process.js:415:16)
17 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)

It appears that child_process is attempting to call /usr/bin/zsh. However, I am uncertain why or how to resolve this issue. Any suggestions?

This dilemma bears resemblance to the one discussed here: Trying to run concurrently (npm ERR! code ELIFECYCLE npm ERR!)

Despite a full reinstallation of node, npm, and nvm, the problem persists. The error also manifests when using yarn.

Another puzzling observation:

I am unable to locate internal/child_process.js or internal/process/next_tick.js anywhere.

Edit: Regardless of the executed script, this error occurs consistently.

If I execute a script npm run x, which is defined in package.json as "x"="npm run y", it fails. However, running npm run y directly functions as expected.

Answer №1

Successfully bypassed two security measures on OSX to temporarily resolve this issue:

  1. Disabled SIP (system integrity protocol) by entering recovery mode (holding CMD + R), navigating to Utilities -> Terminal, and executing csrutil disable
  2. Removed write protection from /usr/bin with the following commands:

    sudo mount -uw / killall Finder

    1. Established a symlink using ln -s /usr/bin/zsh /bin/zsh

The error has been eliminated for now, but the root cause remains elusive along with a permanent solution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Problem encountered when executing "npm run dev" in Vue.js with vue-cli

My current setup: Running Centos7 on VirtualBox (host OS : Windows 7) Node version: 6.10.3 Npm version : 3.10.10 Operating behind a corporate proxy I went ahead and installed vue-cli using the following command: sudo npm install -g vue-cli After that, ...

Removing error messages upon form reset initiated by an API request

Is there a way to clear error messages that appear beneath a text field when resetting form fields with values from an api call? In my Formik form, I have three fields that are loaded from an api database call along with a Reset button that reloads these ...

There is no 'Access-Control-Allow-Origin' header on the resource you requested, so access from 'localhost ' is not permitted

I'm trying to retrieve JSON data by passing a URL, but I keep encountering an error that states: Failed to load https://sample-dec42.firebaseapp.com/one.json: Response to preflight request doesn't pass access control check: No 'Access-Contr ...

What are the best practices for utilizing an array of routes?

I'm new to working with react but I noticed something strange. My routes are currently set up like this: <Main> <Route exact path="/home" component={Home} /> <Route exact path="/home1" com ...

How can I create a redirect link in HTML that opens in a new window

I have a HTML page where I need to redirect to the next page. <a href="www.facebook.com" target="_blank">www.facebbok.com</a> Currently, it is redirecting to localhost:9000/dashboard/www.facebook.com But I only want to redirect to www.facebo ...

Can a YouTube video be triggered to play when a specific CSS style is selected?

I am searching for a method to display and play different YouTube videos based on a selected CSS style from a drop-down menu. I believe JavaScript can be utilized to detect the chosen CSS. Include the following in the html header of the page. <script ...

The integration of Next.js with a Custom Express Server results in incorrect content types being generated for woff and woff2 files

I recently migrated my Next.js app to a new dedicated cpu server on Digital Ocean, and now I'm facing an issue where my fonts are being served with Content-Type: text/html; charset=utf-8, resulting in a 500 error. Strangely enough, this was not a prob ...

Can a MS Teams Bot be triggered to show a botMessagePreview from a task or submit activity rather than a composeExtension or submitAction activity?

As I develop a messaging extension in Teams that utilizes task modules and sends adaptive cards, I am faced with the challenge of invoking the same task module from both a messaging extension command and a button on an adaptive card sent to the user. The ...

Clearing a textarea in jQuery that is populated with text

Having an interesting dilemma. I'm trying to clear a <textarea> and then replace it with new content. The functions in the JSFiddle will work perfectly fine if the textarea is left empty, but as soon as any text is manually typed into it, the me ...

The HTML embed element is utilized to display multimedia content within a webpage, encompassing

Currently, I am working on a static website for my Computer Networks course. Students need to be able to download homework files in PDF format from the website. I have used embed tags to display the files online, but I'm facing an issue where the embe ...

Microphone Malfunction: Abrupt End of Input Detected

I have been experimenting with SpeechRecognition to incorporate microphone functionality into one of my projects. However, when I check the Chrome Console, it displays the error message: Unexpected end of input const speechRecognition = window.webkitS ...

Access the array values by their respective keys in an object that is returned from a custom JavaScript file utilizing the Node.js file system

I recently came across a config file with a unique format, as shown below: define([], function () { return { productItems: { item1: ['Apple', 'Ball', 'Car'], item2: [&apo ...

The additional cost associated with using a React hook is called the "

Our system includes a theme context provider that passes down a theme to all child components, calculated based on the device's dimensions. We can easily access these values using the useTheme hook in any component. In addition, we have a constants f ...

Google Feed API - Retrieving saved data from RSS feed cache

We have implemented the Google Feed API to display our latest blog posts on our website. However, even after 24 hours, our most recent post is still not appearing on our site. Despite confirming that the RSS feed contains the newest content, it seems that ...

Chrome experiences a crash during regular expression matching operations

I have a challenge where I am attempting to validate 50 email addresses separated by commas using regex. Strangely, every time I run this operation, Chrome crashes. However, Safari seems to handle it without any issues. Below is the code snippet that I am ...

The JSON object containing Jest tests in a node.js project is not being parsed correctly

Within my codebase, I have defined an object with the following interface: export interface range { max: number, min: number } This object is being returned from a GET call, which is initiated by the function outlined below. export async function test ...

Alert: Module 'events' in base/lib is not found

Whenever I try to run Ghost 0.5.0, an error message pops up saying ERROR: Cannot find module './lib/base/events'. I've tried uninstalling and reinstalling the events module multiple times with the -g flag, but it still doesn't seem to ...

Switching Primary Menu Selection When Scrolling Through Various Menu Options

I need help with changing the active class of links on my single page scrolling website. I found some useful code snippets for smooth scrolling and updating the active class on scroll or click events: $(document).ready(function () { $(document).on(" ...

Setting up karma on the cloudbees platform

I'm attempting to set up karma for cloudbees/jenkins. In the pre-build script, I've included the following: # install nodejs, if using cloudbees curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/us ...

Automatically populating username and password fields

Is it possible to set up automatic username and password filling on my website for users who have saved their login information in their browser? I want the user to just hit enter to login. Some websites already have this feature enabled, but others requi ...