React Cannot Start Project - 'craco' is not recognized as an internal or external command
Asked Answered
M

4

11

is anyone able to tell me why I cannot start up my website project on the development server?

I've cloned a file on Windows 10, this used to work fine on my Mac OS ... before it died :'(Feel free to try the project: https://github.com/EMDevelop/j2c

When I run npm start, I get the following message

> [email protected] start C:\Users\Ed\Desktop\Coding\React\j2c
> craco start

'craco' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start 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:
npm ERR!     C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_11_19_513Z-debug.log

This is strange because I have "craco": "0.0.3" as a dependency, and "start": "craco start" as a script within my package.json.

I also have the craco.config file within the project, and @craco folder in the node_modules folder.

When I then try and install craco again (npm i @craco/craco) and run npm start, i get the below error asking me to install the dependencies:

C:\Users\Ed\Desktop\Coding\React\j2c>npm i @craco/craco
npm WARN [email protected] requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^15.3.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.5.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native-vector-icons@>7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native-safe-area-context@^3.1.9 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.

npm ERR! code EEXIST
npm ERR! path C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco
npm ERR! Refusing to delete C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco: is outside C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\@craco\craco and not a link
npm ERR! File exists: C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_29_51_457Z-debug.log

This is strange also because I have most of these dependencies inside of the node_modules folder (and package.json):

Packages.Json Screenshot

I'm concerned about just recklessly forcing craco to replace the old version, and will I then have to do that for every dependency it has given me the warning for? most of which dependencies already exist.

Then when I try and run npm start again, it gives me the error as if I never had craco installed again:

C:\Users\Ed\Desktop\Coding\React\j2c>npm start

> [email protected] start C:\Users\Ed\Desktop\Coding\React\j2c
> craco start

'craco' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start 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:
npm ERR!     C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_30_25_218Z-debug.log

Any help would be greatly appreciated!! pulling my hair out, I'm new to Windows.

Mcelroy answered 26/3, 2021 at 16:43 Comment(0)
G
21

This worked for me

npm install @craco/craco --save
Garnett answered 16/4, 2021 at 9:4 Comment(1)
I've tried that, reopened the terminal again and still says 'craco not found' ...Urology
B
2

This is Tailwind css specific error with React Applications.

Since Create React App doesn’t let you override the PostCSS configuration natively, we also need to install CRACO to be able to configure Tailwind. But somehow craco is not installed on your project.

So we have to do is :

npm install @craco/craco

OR

npm install @craco/craco --save
Broad answered 2/11, 2021 at 3:21 Comment(1)
--save has no effect from npm 5 its added as by defaultArlyne
A
2

make sure craco if you cant use this command

npm install @craco/craco --legacy-peer-deps

make sure craco.config.js to be like this

// craco.config.js
module.exports = {
    style: {
       postOptions: {
        plugins: [
          require('tailwindcss'),
          require('autoprefixer'),
        ],
      },
    },
  }
Arlyne answered 17/1, 2022 at 17:53 Comment(0)
I
1

First, check @craco/craco version in package.json file

  npm install @craco/[email protected] --save
              OR 
  yarn add @craco/[email protected]           

5.8 is a version of craco in package.json file.

and close editor and reopen try to run

Irresolution answered 24/1, 2022 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.