Npm start is compiling too long

Npm start is compiling too long
0

#1

Hi there,
When I try to run react application by typing “npm start” compiling takes about 15 seconds.
I don’t get any errors. In other apps compiling is very short (1 sec) What is the cause of it? Webpack issue?


#2

Maybe.
Show us package.json file


#3
{
  "name": "react-complete-guide",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "autoprefixer": "9.4.7",
    "axios": "^0.18.0",
    "babel-core": "6.26.3",
    "babel-eslint": "10.0.1",
    "babel-jest": "24.0.0",
    "babel-loader": "8.0.5",
    "babel-preset-react-app": "^7.0.0",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.2.0",
    "chalk": "2.4.2",
    "css-loader": "2.1.0",
    "dotenv": "6.2.0",
    "eslint": "5.13.0",
    "eslint-config-react-app": "^3.0.6",
    "eslint-loader": "2.1.1",
    "eslint-plugin-flowtype": "3.2.1",
    "eslint-plugin-import": "2.16.0",
    "eslint-plugin-jsx-a11y": "6.2.0",
    "eslint-plugin-react": "7.12.4",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "3.0.1",
    "fs-extra": "7.0.1",
    "html-webpack-plugin": "^4.0.0-beta.5",
    "jest": "24.0.0",
    "object-assign": "4.1.1",
    "postcss-flexbugs-fixes": "4.1.0",
    "postcss-loader": "3.0.0",
    "promise": "8.0.2",
    "prop-types": "^15.6.2",
    "react": "^16.7.0",
    "react-dev-utils": "^7.0.1",
    "react-dom": "^16.7.0",
    "style-loader": "0.23.1",
    "sw-precache-webpack-plugin": "0.11.5",
    "terser": "^3.14.1",
    "url-loader": "1.1.2",
    "webpack": "4.29.0",
    "webpack-dev-server": "3.1.14",
    "webpack-manifest-plugin": "2.0.4",
    "whatwg-fetch": "3.0.0"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.js?(x)",
      "<rootDir>/src/**/?(*.)(spec|test).js?(x)"
    ],
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}


#4

I was expecting to see some ancient version of webpack or babel, but everything seems quite fresh.

Post a link to the repo, I’ll try on my computer.


#5

Here it is: github repo


#6

@axon7 I tested your repo on my local pc and it starts in about 14 seconds the first time I run npm start and about 4-5 seconds on subsequent runs. I would not worry about it too much. The first time npm start is ran, I believe it will always take a bit longer.


#7

I don’t think it’s normal. I’ve got 20 seconds on my stopwatch when just I changed some letter and hit save :frowning:


#8

@RandellDawson
Try to edit some files and see how long recompiling takes. For me initial start is about 15s, recompiling 10…15s, which is too long.

@axon7
It looks like an ejected crate-react-app, and probably someone did some modificatons in config files.
Easiest way would be to create a new app with create-react-app and just copy the src files

EDIT:
Found it. config > webpack.config.dev.js, Line 29 change to ‘development’


#9

Hurray! Thank you :blush: