spring-attic / tut-react-and-spring-data-rest

React.js and Spring Data REST :: A tutorial based on the 5-part blog series by Greg Turnquist
https://spring.io/guides/tutorials/react-and-spring-data-rest
882 stars 1.58k forks source link

How to add new dependencies on package json? #85

Closed pugzangpangalan closed 5 years ago

pugzangpangalan commented 6 years ago

hi,

i am currently trying to add axios as a dependencies, but every time I add it as require('axios '). it will give me and error stating "axios is not defined".

below is my package.json snippet

"dependencies": { "react": "^15.3.2", "react-dom": "^15.3.2", "rest": "^1.3.1", "webpack": "^1.12.2", "axios": "^0.16.2" },

pugzangpangalan commented 6 years ago

checking on the version of axios on node_modules it is currently installed.

/node_modules$ npm view axios version 0.18.0

but if i try to access it on localhost:8080

it is still have an error

external "axios":1 Uncaught ReferenceError: axios is not defined

gregturn commented 6 years ago

Did you run webpack and have it complete the build? Any results there?

pugzangpangalan commented 6 years ago

how do i do that?

emeidell commented 6 years ago

If you only added it to the package.json without running npm install it would not do anything. Another way of doing it is to run npm install --save axios. Doing that will install and add it to your package.json for you.

gregturn commented 5 years ago

frontend-maven-plugin is the secret sauce to running nodeJS commands inside your maven build.

To use the version of Node + NPM + Webpack as configured in the project, do this:

$ cd basic
$ ./mvnw frontend:install-node-and-npm
$ ./mvnw frontend:npm
$ ./mvnw frontend:webpack
gregturn commented 5 years ago

Feel free to reopen if you need further assistance with building JS artifacts.

Ajeeth-07 commented 1 year ago

If you only added it to the package.json without running npm install it would not do anything. Another way of doing it is to run npm install --save axios. Doing that will install and add it to your package.json for you.

I used this command to install axios it installed successfully but it is not adding or showing the dependency in package.json