0

As you can see i get this error. Has it something to do with my package.json? Default looks like this.

{
    "name": "reactproject",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "react": "^16.12.0",
        "react-dom": "^16.12.0",
        "react-scripts": "3.3.0"
    }
}
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\k12\AppData\Roaming\npm-cache\_logs\2019-12-31T00_09_26_886Z-debug.log
PS C:\Users\k12\reactproject> ^C

After i did the command npm rm -g create-react-app i get the following in the command prompt

Error: EPERM: operation not permitted, mkdir 'C:\Users\k12'
TypeError: Cannot read property 'get' of undefined
    at errorMessage (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-message.js:38:39)
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:201:13)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:171:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:210:5)
    at process._fatalException (internal/process/execution.js:150:25)
Install for [ 'create-react-app@latest' ] failed with code 7

C:\Users\k12>

2 Answers2

0

The error is because you have no start script defined in your package.json

As I don't know what your server set up is, I cannot say what is should be exactly. But something along the lines of:

"scripts": {
    "start": "node index.js",
}
T. Short
  • 3,481
  • 14
  • 30
  • Can you try to read my post again i tried to remove an older version and now i cannot create-react-app –  Dec 31 '19 at 01:07
0

Looking at your package.json, your project seems to be a Create React App project without a template. This occurs when you have an older, globally installed CRA on your machine. The default template package.json should look like this:

{
  "name": "test3",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-scripts": "3.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Remove the globally installed version (npm rm -g create-react-app) and try again with npx create-react-app reactproject

See the https://create-react-app.dev/docs/getting-started guide for more information.

Pete TNT
  • 8,293
  • 4
  • 36
  • 45
  • Yes i did that. I created my project with the following. –  Dec 31 '19 at 00:20
  • Be sure that you don't have a globally installed CRA on your computer (`npm rm -g create-react-app`) and try again. It should notify you about an older version existing if there is one (A template was not provided) – Pete TNT Dec 31 '19 at 00:23
  • when i try to start the new folder the command prompt says i use a older version of create-react-app and therefor no template could be created. –  Dec 31 '19 at 00:27
  • See the comment and updated answer: you must remove the older version first with `npm rm -g create-react-app`. After that try running the command again. If the issue persists then you probably have yet another copy of the create-react-app on your machine. – Pete TNT Dec 31 '19 at 00:30
  • I did what you said. The problem presist. What to do from here? –  Dec 31 '19 at 00:39