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!