I am facing an issue with my ReactJS (Create-React-App) project. It renders successfully on localhost when I run the command npm start
, but encounters an error when I run the build command: npm run build
.
yarn run v1.16.0 $ react-scripts build Creating an optimized production build... Failed to compile.
./src/css/master.css Module build failed: TypeError: $.each is not a function
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Surprisingly, I have not used $.each
function anywhere in my master.css
master.css
@charset "utf-8";
/* CSS Document */
.
.
. (Rest of the CSS styles)
.
package.json
{
"name": "react-express-tutorial",
"version": "0.1.0",
.
. (Package dependencies and scripts)
.
}
index.js
import React from 'react';
.
. (Importing and rendering components)
.
App.js
import React, { Component } from 'react';
.
. (Defining routes using React Router)
.
helper.jsx where jQuery is used:
import React from 'react';
import $ from 'jquery';
.
. (jQuery functions for UI manipulation)
.
It seems that there might be an issue with your jQuery usage or the way you are including it in your project. Make sure to check your imports and how jQuery is being utilized in your helper functions.