This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JavaScript webshop with MySQL DB

 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • 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: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • 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...
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic