Error message "npm: not found" was encountered while attempting to generate a React app using tools like NVM and NPM within

I'm currently working on setting up a new React project in pycharm. Utilizing version 0.34.0 of NVM, I have successfully installed node.

Before initiating the project, here is my pycharm window:

https://i.stack.imgur.com/Opt7z.png

The command npm -v returns 6.9.0

Running whereis npm results in:

npm: /home/usa/.nvm/versions/node/v12.3.1/bin/npm

However, upon attempting to create the React app, an error message appears:

/home/usa/.nvm/versions/node/v12.3.1/bin/node /home/maged/.nvm/versions/node/v12.3.1/lib/node_modules/create-react-app/index.js .

Creating a new React app in /home/usa/Desktop/ny/untitled1.

/bin/sh: 1: npm: not found
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

events.js:177
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn npm',
  path: 'npm',
  spawnargs: [
    'install',
    '--save',
    '--save-exact',
    '--loglevel',
    'error',
    'react',
    'react-dom',
    '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2755424644530a5444554e5753546717091e095f">[email protected]</a>'
  ]
}
Done

Answer №1

If you've installed npm and can see its version, make sure to add it to the PATH variable on your system so other services can easily locate it. To do this, start by running the following command in your terminal:

cat $PATH

Check the output to confirm if the npm path is already included. If not, run the command below and try again:

export PATH=$PATH:/<path-to-npm-bin>/npm/bin

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

Get the value of a specific option within a React-bootstrap Form component

A special Form has been created to retrieve the selected value from an option. import Button from "react-bootstrap/Button"; import Form from "react-bootstrap/Form"; import { useState } from "react"; export default function Cu ...

Please be patient for the PayPal script to load on the nextjs page

I've encountered an issue with my code that is meant to display PayPal buttons <Head> <script src="https://www.paypal.com/sdk/js?client-id=KEY"></script> </Head> The PayPal buttons are loaded within the ...

Deliver JSX components that match one or more keys in the array of strings

Seeking assistance and guidance here. It seems like I might be overlooking something obvious. I am attempting to create a component that accepts either a string or string Array string[] as a property. const ComponentThatReturnsElement = (someElementName) = ...

Encountering a dependency issue while trying to build with NPM

I have been researching peer dependencies with npm, but this error that I am encountering is causing confusion. Can someone assist me in identifying the package responsible for this issue? Despite trying to follow step by step instructions from start to fi ...

What's the simplest method for adjusting the default font in Reactstrap?

Currently working on a MERN project and I want to customize the font used by Reactstrap for my React frontend. While I've come across solutions for altering Bootstrap 4's default fonts, I'm unsure how to implement them in Reactstrap. Any gui ...

Sending arguments to npm ci

Ever since npm ci was introduced some time back, it has become the preferred method for building applications - especially in CI environments and similar scenarios. Currently, I am facing a situation where I need to specify additional options (such as the ...

When attempting to host a React application within an Express server, an error is encountered with the message "

I am looking to host my react app, created with create-react-app, using an express app. This is the express app I have written: const express = require('express') const path = require('path') const app = express() console.log(path.re ...

Unable to complete installation of tensor flow

I recently encountered an issue while trying to install TensorFlow for a machine learning project on my system. Despite having Python 3.7.9 64-bit installed, I faced an error stating: "ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1 ...

Quick inquiry about referencing state variables in the render method in React Native

Initially, I assumed it was just a simple syntax error, but now I'm beginning to think that it might be related to a bigger concept concerning hierarchy and inheritance. I am currently working on an app in react native (expo) where I aim to display a ...

Can we effectively manage the input for a component that is created dynamically in real-time?

Please note: I am a newcomer to ReactJS, JavaScript, and the world of front-end development in general. Hello everyone, I have made the decision to create a versatile component that can handle all the forms within my project based on a predefined templat ...

Create a login page that allows users to authenticate using a post request

I am developing a login page, but facing an issue where even if the entered data is incorrect, it still redirects to the page. How can I resolve this problem? In my table, I only have email and password details. const client = require('../../db' ...

Utilize a NPM package within a Nuxt project

In my quest to create a user-friendly NPM module for project integration, I am envisioning a seamless process where the user can effortlessly import the module without any prior knowledge of Nuxt. The main feature of this module will be a comprehensive adm ...

The Next JS router is failing to return the variable page ID

In my Next.js application, I have implemented a requireAuth component to protect the logged in pages: import useAuth from '../../hooks/useAuth'; import { useRouter } from 'next/router'; import { useEffect } from 'react'; cons ...

Styling components using classes in Material-UI

I recently started using material-ui and noticed that it applies inline styles to each component. After running a test with multiple instances of the same component, I realized that there was no CSS-based styling - only repeated inline styles were generate ...

D3 - Rounded edge chart width

Currently facing an issue with the chart where the data value is small, resulting in an 'ear' effect. Can anyone help me with this problem? Below is the code I am currently using: const rx = 30; const ry = 30; svg ...

When you hover the cursor over it, the material-ui icon button shines with an elliptical background effect

There seems to be a strange issue with the IconButton in @material-ui/core/IconButton that is causing a weird elliptical background to appear when hovering over it. https://i.stack.imgur.com/Xof8H.png Even after copying the code directly from the materia ...

The React Hook Form's useFieldArray feature is causing conflicts with my custom id assignments

My schema includes an id property, but when I implement useFieldArray, it automatically overrides that id. I'm utilizing shadcn-ui Version of react-hook-form: 7.45.0 const { fields, append, remove, update } = useFieldArray<{ id?: string, test?: n ...

Navigating through Next.js pages feels like dragging through molasses, especially when using server

It's clear that this question has been asked before, but the existing answers are not solving my issue. The problem I'm facing is that server-side rendering is taking too long. Moving from page to page is slow, ranging from 2.5-4 seconds and som ...

Challenges arise with data updating following a mutation in @tanstack/react-query

As I work on building an e-commerce website using React, I have a specific feature where users can add products to their favorites by clicking a button. Following this action, I aim to update the profile request to display the user's information along ...

Endless [React Native] onFlatList onEndReached callback invoked

Attempting to create my debut app using ReactNative with Expo, I've hit a snag with FlatList. The components are making infinite calls even when I'm not at the end of the view. Another issue might be related; across multiple screens, the infinite ...