Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

JavaScript webshop with MySQL DB  RSS feed

 
Rancher
Posts: 502
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all except from the basic stuff I have no experience with javascript.
For a friend of mine I'm trying to make a small webshop in javascript but I have trouble connecting the app to my db.
I'm using npm mysql2 to do so. When I run only the javascriptcode everything works fine, so I'm sure the needed packages are installed and my dependencies are in order.
But when running the full website I get the console-error require is not defined.
After a search I read that require is runs serverside (What ever that means, I thought the whole point of js is that it is run in the browser) and the browser dosn't know what to do with it.
People suggest to use express or require.js.
I couldn't for the love of god don't find a good tutuorial that explains me how to us express ccombined with a db, all the expamples I've seen seemed to start a webserver.
So I tried to us require.js, but when doing so I get this error:



which means I should use require["mysql1", function("mysql2")], but when I trie to do so, my ide gives me an error saying that require has a wrong number of arguments.

Anyone who can point me in the right direction?
 
Marshal
Posts: 67163
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there actually a problem at run-time? IDE errors and warnings are notoriously unreliable.
 
Daniel Demesmaecker
Rancher
Posts: 502
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear

As a mather of fact, it does, but not the one expected.


So apperently it's looking in the wrong directory.
I read online that you're suposed to list the dependend modules in the dependency array in the require.js file, but couldn't for the love of god find it...
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!