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

Issue: Property is not found within the parameters of the Generic Type

Currently, I am delving into the world of Typescript and have been exploring various exercises that I stumbled upon online. However, I have encountered some trouble with the feedback on incorrect solutions. Specifically, I am facing an issue with the follo ...

Tips for utilizing parameters within SQL Server

Hello everyone! I am new to SQL Server in Azure functions using Typescript. I am currently facing an issue while trying to update a row in the database using declared variables, particularly with VARCHAR types. Strangely, it works fine in the database tool ...

Error encountered in Angular 7.2.0: Attempting to assign a value of type 'string' to a variable of type 'RunGuardsAndResolvers' is not allowed

Encountering an issue with Angular compiler-cli v.7.2.0: Error message: Types of property 'runGuardsAndResolvers' are incompatible. Type 'string' is not assignable to type 'RunGuardsAndResolvers' This error occurs when try ...

Node's getRandomValues() function is throwing an "expected Uint8Array" error

Currently, I am experimenting with the getRandomValues() function to enhance an encryption REST API that I am developing for practice. My server is using Node, which means I do not have access to a window object containing the crypto object normally housin ...

Duplicate responses being sent by Discord bot

Currently working on a discord.js bot, I've encountered an issue where it responds to commands twice. It seems to be caused by too many instances running simultaneously. When attempting to delete these instances, they often persist and display the mes ...

Running two servers at the same time using nodemon might seem complex, but it

Is it possible to run two servers (www.js and apiServer.js) simultaneously using nodemon? I have set the value for the "start" key in package.json as https://i.stack.imgur.com/r8M7p.jpg After running nodemon in the command prompt with the current working ...

Are you ensuring compliance with licensing in your Webpack bundles?

Can webpack be used to verify license compliance? I'm looking for a way to ensure that the license headers from all modules built by webpack are included in the final output file. How can we confirm this is happening? Furthermore, I am also intereste ...

Travis had a setback with his push, but he successfully passed the

Why did Travis report a build failure for the latest push but passed the Pull Request? In this Gist, you can access the output logs for both the failed and successful executions of the npm run build command provided by Travis. The configuration details of ...

Guide on invoking child components' functions from the parent component in Angular 6

Main Component import { Component } from '@angular/core'; import { DisplayComponent } from './display.component'; @Component({ selector: 'my-app', template: ` <button (click)="submit()">Call Child Com ...

Execute a function once an observable variable has been successfully initialized

I'm currently putting together a chat application using socket.io in Angular. I've encountered an issue where I can't seem to execute a particular code or function right after an observable variable is initialized through subscription. The i ...

Typescript - Defining string value interfaces

I have a property that can only be assigned one of four specific strings. Currently, I am using a simple | to define these options. However, I want to reuse these types in other parts of my code. How can I create an interface that includes just these 4 va ...

Does the TS keyof typeof <Object> rule prohibit the assignment of object.keys(<Object>)?

I'm having trouble understanding the issue with this code snippet. Here is the piece of code in question: export type SportsTypes = keyof typeof SportsIcons export const sports: SportsTypes[] = Object.keys(SportsIcons); The problem arises when I at ...

Create a personalized button | CKEditor Angular 2

I am currently working on customizing the CKEditor by adding a new button using the ng2-ckeditor plugin. The CKEditor is functioning properly, but I have a specific requirement to implement a button that will insert a Rails template tag when clicked. For ...

Error TS2304: Unable to locate the word 'InputEvent'

While exploring the topic of whether TypeScript has type definitions for InputEvent, I experimented with using @types/dom-inputevent in my Angular 7 project. However, I kept encountering the error TS2304: Cannot find name 'InputEvent' whenever I ...

Steps for modifying the global installation path for npm:

Is there a way to specify a different installation path for global dependencies when using npm install -g module? Currently, I notice that it installs them in my C:/../{name}/Appdata..etc, but due to limited disk space, I need to change this location. I h ...

How can I set up multiple queues in NestJs Bull?

My goal is to set up multiple queues in NestJs, and according to the documentation: You can create multiple queues by providing multiple comma-separated configuration objects to the registerQueue() method. However, I am encountering an issue where VSco ...

"Retrieving an element from an array may result in a value of

While going through an array of objects in my Angular component class, I faced a strange issue where the properties kept showing up as undefined. The function responsible for this behavior looks like this: upload(): void { const { fileHandles, related ...

What is the recommended default value for a file in useState when working with React and TypeScript?

Can anyone help me with initializing a file using useState in React Typescript? const [images, setImages] = useState<File>(); const [formData, setFormData] = useState({ image: File }); I'm facing an issue where the file is sho ...

Tips for effectively generating a JSON object array in Typescript

Currently, I'm attempting to construct an array of JSON objects using TypeScript. Here is my current method: const queryMutations: any = _.uniq(_.map(mutationData.result, function (mutation: Mutation) { if (mutation && mutation.gene) { co ...

Missing folders in npm package

After successfully creating and publishing a private npm package, I noticed an inconsistency in the file structure when installing it on another project: Library.Util | |__index.js | |__package.json The original file structure of the package includes a t ...