Because when I install Axios in my next application I can’t run it?

Asked

Viewed 170 times

-1

I’m learning Nextjs and wanted to create a project with Next and Axios but whenever I install Xios the application stops working. Note: this project also has Typescript and Styled-Components

Commands:

1 - npx create-next-app app --example with-typescript-styled-components
2 - cd app
3 - npm install axios
4- npm run dev

Error

'next' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `next`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\diego\AppData\Roaming\npm-cache\_logs\2021-05-07T19_28_05_002Z-debug.log

package json.

{
  "name": "with-typescript-styled-components",
  "version": "1.0.0",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "axios": "^0.21.1",
    "next": "latest",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-is": "^17.0.2",
    "styled-components": "^5.2.3"
  },
  "devDependencies": {
    "@types/node": "15.0.0",
    "@types/react": "17.0.4",
    "@types/react-dom": "17.0.3",
    "@types/styled-components": "5.1.9",
    "babel-plugin-styled-components": "^1.12.0",
    "typescript": "4.2.4"
  },
  "license": "MIT"
}

  • We would need more information to help, could share your package.json and what the project shows when you don’t have Axios installed?

  • i can’t run it locally. It still shows only next default screen

1 answer

0


The mistake is in yours package.json, the script dev is as:

{
  "dev": "next"
}

When it should be:

{
  "dev": "next dev"
}
  • I tried, but you’re still making the same mistake

  • I created a PR there, see if the branch will run

Browser other questions tagged

You are not signed in. Login or sign up in order to post.