• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

JavaScript webshop with MySQL DB  RSS feed

 
Rancher
Posts: 1170
18
Firefox Browser 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: 67257
170
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: 1170
18
Firefox Browser 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...
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!