24

something has changed in my program structure and due to its complexity i cannot exactly point where the problem. Ever since my application crushed and no longer working i have tried different approaches like deleting the node module packages and reinstalling them but still wont work. whenever i try to run npm start i get the following errors:

enter image description here

below is my project structure enter image description here

And below is my package.json file

   {
    "name": "events-react-app",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
    "autoprefixer": "7.1.6",
    "axios": "^0.17.1",
    "babel-core": "6.26.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-preset-react-app": "^3.1.1",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "css-loader": "0.28.7",
    "dotenv": "4.0.0",
    "dotenv-expand": "4.0.1",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "4.10.0",
    "eslint-config-react-app": "^2.1.0",
    "eslint-loader": "1.9.0",
    "eslint-plugin-flowtype": "2.39.1",
   "eslint-plugin-import": "2.8.0",
   "eslint-plugin-jsx-a11y": "5.1.1",
   "eslint-plugin-react": "7.4.0",
   "extract-text-webpack-plugin": "3.0.2",
   "file-loader": "1.1.5",
   "fs-extra": "3.0.1",
   "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
   "object-assign": "4.1.1",
   "postcss-flexbugs-fixes": "3.2.0",
   "postcss-loader": "2.0.8",
   "promise": "8.0.1",
   "raf": "3.4.0",
   "react": "^16.2.0",
   "react-dev-utils": "^5.0.0",
   "react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-test-renderer": "^16.2.0",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
"url-loader": "0.6.2",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
},
 "scripts": {
 "start": "node scripts/start.js",
 "build": "node scripts/build.js",
 "test": "node scripts/test.js --env=jsdom"
},
 "jest": {
  "collectCoverageFrom": [
  "src/**/*.{js,jsx,mjs}"
   ],
 "setupFiles": [
  "<rootDir>/config/polyfills.js"
  ],
  "testMatch": [
  "<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
  "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
],
   "testEnvironment": "node",
"testURL": "http://localhost",
"transform": {
  "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
  "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
  "^(?!.*\\.(js|jsx|mjs|css|json)$)": " 
   <rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
  "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
],
"moduleNameMapper": {
  "^react-native$": "react-native-web"
},
"moduleFileExtensions": [
  "web.js",
  "mjs",
  "js",
  "json",
  "web.jsx",
  "jsx",
  "node"
]
  },
   "babel": {
"presets": [
  "react-app"
]
},
  "eslintConfig": {
"extends": "react-app"
   }
}
7
  • Have you run npm install yet? Commented Apr 8, 2018 at 7:35
  • It sounds like create-react-app was used to create this application initially, and that create-react-app added a scripts/ folder with scripts to run the project. That scripts/ folder should have been added to source control, so that checking it out again would result in it still being there. You may need to use create-react-app again to get that scripts/ folder back Commented Apr 8, 2018 at 7:41
  • yes, i have tried several times but still cannot make to work Commented Apr 8, 2018 at 7:41
  • your package.json has a scripts section, which lists start command as node scripts/start.js, but it seems like there is no file scripts/start.js. When you run npm start, it just looks at that value and runs it. You'll need to figure out where it originally came from, and get it back. Commented Apr 8, 2018 at 7:45
  • i tried to follow your lead to use create - react-app to get the script folder back but cant see any folder named script Commented Apr 8, 2018 at 10:20

8 Answers 8

52

react-scripts start generates error Error: Cannot find module '../scripts/start'

I'm not sure what is causing the problem during the create react app, but the thing I found that works best is simply delete the nodes_module folder then in Terminal run npm install in the project directory.

Reference: Npm start fails

Sign up to request clarification or add additional context in comments.

5 Comments

I did the same. The root cause of the issue was, I copied the whole directory from another app and tried to run.
Same...I had copied my react app into a new folder. I read this post, deleted my node_modules directory, ran npm install, and then said "voila"
I use two diff machines and Dropbox synced over the node_modules folder from one machine to other. This solution resolved it for me.
Agree. I faced the problem in the question when I converted my project into a git repository. Initiated git repository using git init . and committed and pushed my changes. Removing the nodes_module and doing npm install again worked well!
The actual problem is that a lot of ways of copying do not copy/preserve the symlinks; under linux/mac use cp -a to copy react projects and everything is fine!
10

Remove node module folder rm -rf node_modules

Install node modules npm install

Run the project npm start

Comments

5

Updating create-react-app fixed the issue for me.

npm install -g create-react-app@latest

Also, remember it's not node start, it's npm start

Comments

1

I have the same problem when working in WSL2, I copied the reactjs-app to home directory to WSL2. So to resolve it when working on there, delete node_modules and run again npm install inside the app directory.

Comments

0

I think i got the answer . The script/ folder was accidentally placed in the wrong directory it should be in the root folder of my application. i placed it in the root folder and the app is now running as it was . thank you for your lead.

Comments

0

I had the same issue then I solved it this problem with rename root folder name. Remove folder name if folder name contain any symbol like & etc. then try with this command

    npm start

  
    

    

Comments

0

I had already tried rm yarn.lock && rm -rf node_modules && yarn && yarn start but it didn't work.

Eventually I realized that my project had 2 inner projects, too!

So I needed to delete the inner yarn.lock files and node_modules folders and then run yarn && yarn start from the outer level.

That worked.

Comments

0

I solved this issue by reverting my repo to a previous commit before I started getting this issue. I made sure my package.json and package-lock.json files didn't have either of the name of the modules that stopped the build from compiling. At this point, I didn't have the modules folder in the project file-structure either, indicating a clean node package. Then I did a npm install and the app finally compiled.

Hope that helps! Good vibes!

Here's the root cause of my issue - I was trying to install 2 packages using the npm install <name_of_module> command but the install kept returning errors without installing fully. I decided to go to the packages' GitHub repos and clone the files onto my rig and manually add the files as a component, add the packages files in the modules folder, and manually include the package names and versions into the package.json file. I did all of that and ran a npm install command that broke my dev environment.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.