Issues with NPM start arise moments after incorporating create react app typescript into the project

I've encountered an error while trying to initiate my create react app with Typescript. Despite following all the necessary steps, including adding the .env file (with SKIP_PREFLIGHT_CHECK=true) and updating/reinstalling NPM, I keep facing this issue. What should be my next course of action?

> Executing task: npm run start <


> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f0216420e1f1f2f5f415e415f">[email protected]</a> start C:\Users\raahi\OneDrive\Desktop\typescript-react\my-app
> react-scripts start


Upon investigation, it appears there is a complication within the project's dependency tree. This could possibly not be a bug originating from Create React App, but rather an issue that needs local fixing.

The react-scripts package provided by Create React App mandates a specific version of "babel-jest": "^26.6.0".

Avoid attempting manual installation as your package manager handles this process automatically. A different version of babel-jest seems to be detected at a higher level in the directory structure:

  C:\Users\raahi\node_modules\babel-jest (version: 24.9.0)

Installing incompatible versions manually can result in challenging-to-resolve issues.

To remedy the dependency tree discrepancy, consider executing the following steps sequentially:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Remove node_modules in your project folder.
  3. Eliminate "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Proceed with running npm install or yarn, depending on your preferred package manager.

In most cases, these actions should suffice to rectify the problem. If still persisting, explore additional troubleshooting measures:

  5. If you utilized npm, install yarn (http://yarnpkg.com/) and repeat the aforementioned steps using yarn instead. npm may encounter challenges due to package hoisting problems which might get resolved in future updates.

  6. Confirm if C:\Users\raahi\node_modules\babel-jest resides outside your project directory. Accidental installations in your home folder could potentially cause such discrepancies.

  7. Execute npm ls babel-jest in your project folder for identifying any unexpected packages (apart from expected react-scripts) installing babel-jest.

Should none of the above solutions prove effective, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project to bypass the preflight check if willing to proceed regardless.

Kindly note, we acknowledge the lengthy nature of this message but encourage you to carefully follow the steps outlined above :-) We trust they will provide beneficial insights!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="79140054180909394957485749">[email protected]</a> start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failure observed during execution of <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="74190d5915040434445a455a44">[email protected]</a> start script.
npm ERR! The root cause is likely unrelated to npm. Additional logging output might be available.

npm ERR! Detailed log of this session can be found at:
npm ERR!     C:\Users\raahi\AppData\Roaming\npm-cache\_logs\2021-08-07T19_47_30_824Z-debug.log
The terminal operation "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command npm run start" finished with termination code: 1.

Answer №1

Encountered the same error myself. To address this issue, you can execute npm ls babel-jest command to display all versions of babel-jest installed within your project. You may notice that different dependencies have installed varying versions of babel-jest.

Here is a two-step workaround I found:

  1. Ensure that the dependencies are using the same version of babel-jest by aligning their versions accordingly.
  2. You can utilize the resolutions feature in your package.json file to resolve any version conflicts.
   "devDependencies": {
        // Your dependency versions here
      },
      "resolutions" : {
        // Specify resolutions for babel-jest and jest here
      }

After implementing these changes, when you run npm ls babel-jest, the output should reflect the resolved versions accordingly.

https://i.sstatic.net/Bui9m.png

Answer №2

It appears that an accidental installation has occurred in your home directory. It seems like you are attempting to develop your application within the folder

C:\Users\raahi\OneDrive\Desktop\typescript-react\my-app
, but at some point, unintentional installations may have been made in your home directory
C:\Users\raahi\node_modules\babel-jest

To resolve this issue, you can try deleting the folder C:\Users\raahi\node_modules along with C:\Users\raahi\package.json and C:\Users\raahi\package-lock.json (if they exist), which should fix the problem.

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

In the event that you encounter various version formats during your work

Suppose I have a number in the format Example "1.0.0.0". If I want to increase it to the next version, it would be "1.0.0.1" By using the following regex code snippet, we can achieve this perfect result of incrementing the version to "1.0.0.1": let ver ...

The domain name or IP address does not correspond to the alternate names listed on the certificate

I am currently facing an issue with installing npm packages in my react native project. Every attempt to install a package from npm results in the error message shown below: fitz:tesseractOcrSample fitzmode$ npm i npm ERR! request to https://registry.npmj ...

Supplying information to my ejs template while redirecting

I am currently working on a feature that involves sending data from the login page to the home page when the user is redirected. This data will then be used in the home EJS file. Below is the code snippet I have implemented: module.exports = functio ...

Error: Unable to call function onPopState from _platformLocation due to TypeError

After building an angular application, I encountered a strange issue where it runs smoothly in non-production mode but throws an error when running with --prod: Uncaught TypeError: this._platformLocation.onPopState is not a function I have double-checked ...

What is the best way to hand off a component to a helper function?

I am trying to create a helper function in TypeScript that takes a component as an argument and returns an array of objects, each containing a component node... // helpers.ts import { LINKS } from '../constants'; // error on the next line: Cannot ...

Implementing global user authentication state with Zustand in Next.js version 13.4.9

I'm grappling with incorporating zustand into my Next.js 13.4.9 app, specifically for managing global authentication state. Below is the code snippet I have in my application: zustand store: // /src/store/AuthStore.ts import { create } from 'zu ...

Unable to update the color of material icon using document.getElementById(item) method

if (document.getElementById(item).style.color == "grey") { document.getElementById(item).style.color = "red"; } <i class="material-icons" [ngStyle]="post.isLiked != null ? {'color': 'red'}: {'color': 'grey'}" id ...

Injection of environmental variables into app services

Through the use of Nx, I have created multiple apps that each have their own environment with different API URLs. The Nx Workspace library includes shared services that are utilized among all apps, however, it is necessary to pass the environment-api-url w ...

​Troubleshooting findOneAndUpdate in Next.js without using instances of the class - still no success

After successfully connecting to my MongoDB database and logging the confirmation, I attempted to use the updateUser function that incorporates findOneAndUpdate from Mongoose. Unfortunately, I ran into the following errors: Error: _models_user_model__WEBPA ...

How can I pass additional props that are not specified in the interface while working with a React TS component?

I am working with a TS React component called MyButton.tsx: import React from 'react' interface MyButtonProps { children: JSX.Element | JSX.Element[], className?: string, variant?: 'big-button' | 'medium-button' | &apos ...

Issues arise with Typescript Intellisense in Visual Studio Code causing it to stop functioning

I'm currently exploring the world of building desktop applications using Electron and Typescript. After selecting Visual Studio Code as my IDE, everything was going smoothly and I managed to successfully load a sample HTML file into Electron. However ...

Using Typescript: accessing all properties from a specified type while excluding one

Currently working in React, I am interested in extending my type from another, with the exception of some props. This is how I want to approach it : import React from 'react'; import { withTheme } from 'styled-components'; import SvgBa ...

Having trouble getting dependencies to install with bower for foundation new project

I recently followed a tutorial to set up Foundation on my Windows 8.1 PC. However, when I reach Step 16, my command prompt seems to be stuck on "Installing dependencies with bower...". In the past, I have successfully used Foundation on this computer, bu ...

The operation failed because the property 'dasherize' is inaccessible on an undefined object

While attempting to execute the following command: ng generate component <component-name> An error occurred saying: Error: Cannot read property 'dasherize' of undefined Cannot read property 'dasherize' of undefined The confi ...

"Launching" conduit for Observable

Is there a way to attach two pipes to an HttpClient request in order to execute functions at the beginning and end of the request? I have discovered the "finalize" operator for executing a function when the request is finished, but I am looking for an equi ...

Unable to send JSON data from server to client following a successful file upload operation

I'm currently working on a project that involves NodeJS, Express, JQuery, and Typescript. The issue I'm facing is related to uploading a file from the front end, which is successful. However, I'm encountering difficulties in returning a JSON ...

What is the hostname that npm install directs to?

My task is to set up multiple Node.js packages using npm on a standalone server that does not have direct internet access. I am able to specify an IP Address and port for access. When executing 'npm install' from the command line, where can I f ...

Fetching data from an API using Observables in Angular

I am facing a challenge with an API endpoint that returns an array of strings in JSON format. My goal is to display these contents on a webpage using an Angular Service. Below is the code snippet I have implemented so far (working with Angular 7): export ...

Restricting a checkbox to a maximum of 5 checkmarks

In a multi-column table, each column is represented by a checkmark. I want to limit the ability to tick a checkmark to only 5 checkmarks. Here is the code that has been implemented: <tbody> <ng-container *ngFor="let col of testData" ...

Stop the npm start command with a specific error message if the file is not found in the repository

Can the npm start process be stopped or cancelled if a specific file is not found in your codebase? I am looking to end the process if the file dev-variables.js is missing, preferably displaying a custom error message like "You are missing the dev-variabl ...