I recently started working on a new game written in nodejs and for some reason its not letting me use require in the app.js which I know for a fact its possible because I made other games like this
This is the error I am recieving in my console on the website Uncaught ReferenceError: require is not defined at app.js:2
And this is the code its reffering too
var socket;
var pg = require('pg');
var config = require('../../config.json');
var conString = config.database.uri;
var client = new pg.Client(conString);
client.connect();
This error is hendering the rest of my code from running and im almost certain that this line
var config = require('../../config.json');
Will produce an error as well after i fix the first
According to webpack npm and all my other projects doing putting "build": "webpack"
is supposed to allow require in app.js but its not working
Here is my package.json
{
"name": "CodingIdleMasters",
"version": "0.0.1",
"description": "Placeholder",
"main": "server/server.js",
"scripts": {
"build": "webpack",
"start": "node server/server.js"
},
"author": "FlamingGenius",
"contributors": [
"Joseph Williamson <deathcrow4561@gmail.com> (https://github.com/FlamingGenius)"
],
"dependencies": {
"express": "^4.13.4",
"socket.io": "^1.4.6",
"socket.io-client": "^1.4.6",
"webpack": "^1.13.1",
"webpack-stream": "^3.2.0",
"pg": "^1.0.0"
}
}
Here is a link to the project on github in case you need to see more code Github Project
via swiftyprogrmer
No comments:
Post a Comment