The file or directory npx-cli.js cannot be found in the specified location: ../npm/bin/

Problem Description

After creating a new React project using the command below,

npx create-react-app my-app --template typescript

and utilizing node version v18.15.0, I attempted to set up Prettier for the project following the instructions in the Prettier installation section.

I executed the following commands:

npm install --save-dev --save-exact prettier
echo {}> .prettierrc.json

Then, I created a .prettierignore file in the root directory with contents as shown below:

# Ignore artifacts:
build
coverage

Next, I added the format script in my package.json:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "format": "npx prettier . --write"
  }

Upon running npm run format, I encountered the following error:

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5c3125713d2c2c1c6c726d726c">[email protected]</a> format
> npx prettier . --write

<PATH-TO-PARENT-DIRECTORY-OF-PROJECT>/node_modules/.bin/npx: line 1: ../npm/bin/npx-cli.js: No such file or directory

Note that other scripts mentioned above execute without any issues. The problem seems to be related to the npx command itself.

System Information

Device: MacBook Pro 16-inch, 2021, Apple M1 Pro chip, macOS Venture 13.14.1

Seeking assistance in resolving this issue. Any help is appreciated!

Answer №1

After discovering that the main directory of the project contained a specific node_modules folder, I made the decision to remove it. Surprisingly, this simple action resulted in everything functioning correctly. The reason behind this sudden improvement remains unclear to me.

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

Is it beneficial to dockerize an AngularJS + nginx codebase?

Currently, I am working on an AngularJS front-end project that is hosted on nginx and communicates with a back-end Java server (which is not part of this codebase). Each time I need to install the package, I run the following commands: # ensure that node, ...

How to extract component prop types in Vue 3 with typescript for reusability in other parts of your application

When you specify the props under the "props:" key of a Vue component, Vue can already automatically determine their types, which is quite convenient. However, I am wondering if there is an utility type in Vue that can be used to extract the props' ty ...

Angular 10 Reactive Form - Controlling character limit in user input field

I'm currently developing an Angular 10 reactive form and I am looking for a way to restrict the maximum number of characters that a user can input into a specific field. Using the maxLength Validator doesn't prevent users from entering more chara ...

Guide on removing a key from an object in TypeScript

My variable myMap: { [key: string]: string[] } = {} contains data that I need to modify. Specifically, I am trying to remove a specific value associated with a certain key from the myMap. In this case, my goal is to delete value1 from myMap[Key1]. Despit ...

Login attempt with Clasp unsuccessful: 'Issue encountered while retrieving access token...'

I need help setting up Clasp on my Windows 10 PC for Google Apps Script. I am facing an issue when trying to log in via the command line (clasp login). It opens a browser tab where I log in to Google, and the webpage confirms successful authentication. How ...

What steps do I need to take in order to set up InfluxDB with Nest

As a beginner in the world of software development, I am eager to expand my knowledge and skills. Has anyone had experience operating influxdb with nestjs? If so, I would greatly appreciate it if you could share your past experiences. Thank you for takin ...

What is the method to create a universal type by utilizing attributes from a different type?

In building a type, I aim to create one that can accept the type of another object and generate a different type based on specific properties in that object. Illustrating this concept through code: // Definition representing the types of inputs shown on UI ...

Javascript/Typescript Performance Evaluation

I am looking to create a visual report in the form of a table that displays the count of each rating based on the date. The ratings are based on a scale of 1 to 5. Below is the object containing the data: [ { "Date": "01/11/2022", ...

Understanding and parsing JSON with object pointers

Is it possible to deserialize a JSON in typescript that contains references to objects already existing within it? For instance, consider a scenario where there is a grandparent "Papa" connected to two parents "Dad" and "Mom", who have two children togeth ...

The previous build of node/npm is utilizing -lstdc++ which is incompatible with macOS Catalina

Encountering issues when using an outdated version of node (5.x) on macOS Catalina, attempting to run npm install on a package triggers the installation of node-gyp, resulting in an error. fatal error: 'algorithm' file not found After researc ...

What is the best way to flatten a 2D array using TypeScript?

If I have an array structured like this: [0]: ["id_1"]: prop1: "abc" prop2: "def" ["id_2"]: prop1: "ghi" prop2: "jkl" [1]: ["id_3"]: prop1: "mno" prop2: "pqr" ["id_4"]: prop1: "stu" ...

Utilizing the useSearchParams() function to retrieve live data in Next.js

Is there anyone who has successfully migrated from the pages router to the app router in Next.js? I am facing an issue with dynamic data migration. In the pages router, dynamic data is retrieved on a page using useRouter().query, but in the app router, it ...

Bringing in a feature within the Vue 3 setup

At the moment, I am attempting to utilize a throttle/debounce function within my Vue component. However, each time it is invoked, an error of Uncaught TypeError: functionTD is not a function is thrown. Below is the code snippet: useThrottleDebounce.ts imp ...

What purposes does a watchman serve in React Native development?

Is there an easy way to explain the purpose of the watchman tool in the npm library? ----Here's what I discovered--- npm - The biggest package manager for NodeJS NodeJS - A runtime environment for server-side JavaScript Watchman - An uncomplicated ...

Encountering a JavaScript/TypeScript issue that reads "Unable to access property 'Items' as it is undefined"

I encountered an issue with Javascript where I'm receiving an error message stating "Cannot read property 'Items' of undefined". The this keyword is consistently showing as undefined in the Base class. How can this problem be resolved? Coul ...

Combining objects in JavaScript

I am currently working on converting the object received from the server into a format compatible with the backend system. I have a received object that looks like this { 'User.permissions.user.view.dashboard': true, 'Admin.permissio ...

I encountered an error while trying to install image-webpack-loader using NPM. This setback is preventing me from continuing with my project

I had no issues with Webpack all day until I added a new image, then it suddenly stopped working. Even after updating node and npm, I'm still getting the same error message. How can I resolve this problem or find an alternative solution? The other ima ...

Function in Typescript that accepts an array or a single instance of a constructor and then returns a list

UPDATE:: reproducible link to the TypeScript playground I have also found a solution in the provided link, but I am still open to learning why my initial approach didn't work. TLDR; This method does not yield the expected results getEntitiesByComp ...

Saving a JSON object to multiple JSON objects in TypeScript - The ultimate guide

Currently, I am receiving a JSON object named formDoc containing data from the backend. { "components": [ { "label": "Textfield1", "type": "textfield", "key": "textfield1", ...

Need help restarting a timer I've built in Angular with just a click?

I am in the process of developing a compact application that will help me keep track of my activities within a specific time frame. Once I input an activity into a field and click "OK," it should be added to a list. My current challenge lies in resetting ...