getting this error while running the command npm start
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#3.3.12
3 info using node#v5.4.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle passport-local#0.0.0~prestart: passport-local#0.0.0
6 silly lifecycle passport-local#0.0.0~prestart: no script for prestart, continuing
7 info lifecycle passport-local#0.0.0~start: passport-local#0.0.0
8 verbose lifecycle passport-local#0.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle passport-local#0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\.bin;C:\Users\Rohil\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Rohil\bin;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program Files\nodejs;C:\mongodb\bin;C:\Users\Rohil\AppData\Local\Programs\Python\Python35-32;C:\Program Files\MongoDB\Server\3.2\bin;C:\Users\Rohil\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\3.2\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
10 verbose lifecycle passport-local#0.0.0~start: CWD: C:\Users\Rohil\Documents\ddbproject\passport-local
11 silly lifecycle passport-local#0.0.0~start: Args: [ '/d /s /c', 'node ./bin/www' ]
12 silly lifecycle passport-local#0.0.0~start: Returned: code: 1 signal: null
13 info lifecycle passport-local#0.0.0~start: Failed to exec start script
14 verbose stack Error: passport-local#0.0.0 start: `node ./bin/www`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:232:16)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at EventEmitter.emit (events.js:172:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at ChildProcess.emit (events.js:172:7)
14 verbose stack at maybeClose (internal/child_process.js:821:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid passport-local#0.0.0
16 verbose cwd C:\Users\Rohil\Documents\ddbproject\passport-local
17 error Windows_NT 10.0.10586
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 error node v5.4.1
20 error npm v3.3.12
21 error code ELIFECYCLE
22 error passport-local#0.0.0 start: `node ./bin/www`
22 error Exit status 1
23 error Failed at the passport-local#0.0.0 start script 'node ./bin/www'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the passport-local package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error node ./bin/www
23 error You can get their info via:
23 error npm owner ls passport-local
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
tried installing node-gyp
and also cleaning cache, node_modules and running a fresh npm start
even then, i get an error saying module.js:327: throw err;
cannot find module 'mongodb/node_modules/bson'
my package.json file:
{
"name": "passport-local",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "^1.13.2",
"chai": "~1.8.1",
"cookie-parser": "^1.3.5",
"express": "^4.13.1",
"express-session": "^1.10.1",
"jade": "^1.11.0",
"mocha": "~1.14.0",
"mongoose": "^3.8.22",
"morgan": "^1.6.1",
"passport": "^0.2.1",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^1.0.0",
"should": "~2.1.0",
"serve-favicon": "^2.2.0",
"debug": "^2.1.1"
}
}
after running the command npm link mongodb and then running npm start, im getting a new error:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
events.js:141
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:556:25)
at emitThree (events.js:97:13)
at emit (events.js:175:7)
at null.<anonymous> (C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket.<anonymous> (C:\Users\Rohil\Documents\ddbproject\passport-local\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1255:8)
at nextTickCallbackWith2Args (node.js:474:9)
at process._tickCallback (node.js:388:17)
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v5.4.1
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! passport-local#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the passport-local#0.0.0 start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the passport-local package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls passport-local
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Rohil\Documents\ddbproject\passport-local\npm-debug.log
the contents of the ./bin/www file are:
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('passport-local:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
This issue started after editing my app.js file:
// dependencies
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('express-session')({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
// passport config
var Account = require('./models/account');
passport.use(new LocalStrategy(Account.authenticate()));
passport.serializeUser(Account.serializeUser());
passport.deserializeUser(Account.deserializeUser());
// mongoose
mongoose.connect('mongodb://localhost/passport_local_mongoose_express4');
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
module.exports = app;
also created a new file /models/account.js:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var passportLocalMongoose = require('passport-local-mongoose');
var Account = new Schema({
username: String,
password: String
});
Account.plugin(passportLocalMongoose);
module.exports = mongoose.model('Account', Account);
any errors in that?
mongo refuses to start too
$ mongo
MongoDB shell version: 3.2.1
connecting to: test
2016-02-20T23:34:10.083+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-02-20T23:34:10.084+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:224:14
#(connect):1:6
exception: connect failed
The mongoose error might be due to unstable version of mongoose, update "mongoose": "3.8" in package.json. (Followed by npm install) This might remove mongoose warning.
Check this link for
Failed to load c++ extension
Made sure these two packages are at these versions
"mongodb": "^2.1.16",
"mongoose": "^4.4.12"
And running the below commands with reference to here
npm install node-gyp -g
npm cache clean
rm -rf node_modules
npm install
Related
I am having a bit of a hard time getting back to a Node.js project after a while.
I need to implement some new feature and things have changed since I previously worked on that same project.
Here is one error I get in the logs:
2020-02-17T16:42:42.602361+00:00 app[web.1]: Error: Most middleware (like json) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
2020-02-17T16:42:42.602363+00:00 app[web.1]: at Function.get (/app/node_modules/express/lib/express.js:89:13)
2020-02-17T16:42:42.602365+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:57:17)
..........
After reading the net looking for a solution, I added this line to the dependencies section of my package.json file:
"body-parser": "*",
And then to my index.js file I added the following line:
var bodyParser = require('body-parser');
and replaced those two lines:
app.use(express.json());
app.use(express.urlencoded());
by these:
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
It did not solve the problem, so I must be doing something wrong or not be doing all what is needed.
I am no expert in Node.js and am certainly not sure that I correctly used what I may have found on the net. So if someone had relevant advice, that would be more that welcome.
For reference, here is the current package.json file:
{
"name": "parse-server-example",
"version": "1.4.0",
"description": "An example Parse API server using the parse-server module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/ParsePlatform/parse-server-example"
},
"license": "MIT",
"dependencies": {
"#parse/simple-mailgun-adapter": "^1.0.3",
"ejs": "^3.0.1",
"express": "^4.17.1",
"body-parser": "1.19.0",
"kerberos": "~0.0.x",
"parse": "~1.8.0",
"parse-server": "*"
},
"scripts": {
"start": "node index.js"
},
"engines": {
"node": ">=4.3"
}
}
And this is the relevant contents of the index.js file:
var express = require('express');
var bodyParser = require('body-parser');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var mongo = require('mongodb');
var theMgoClient = mongo.MongoClient;
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
// views is the directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
var api = new ParseServer({
databaseURI: databaseUri,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID,
masterKey: process.env.MASTER_KEY,
serverURL: "https://myworld.herokuapp.com/parse",
publicServerURL: 'https://myworld.herokuapp.com/parse',
appName: 'MyGoodApp',
liveQuery: {
classNames: ["MyThings_List"]
},
verifyUserEmails: true,
emailAdapter: {
module: '#parse/simple-mailgun-adapter',
options: {
fromAddress: 'contact868#hmail.com',
domain: 'mydomain.pet',
apiKey: process.env.EML_ADAPTER_KEY
}
}
});
// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT;
app.use(mountPath, api);
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
displayFunc("index", res);
});
app.get('/option1', function(req, res) {
......
});
app.get('/option2', function(req, res) {
......
});
app.get('/option3', function(req, res) {
......
});
app.post('/newStuff', function(req, res) {
......
});
Now, here is what I get when running npm install:
ShellPrompt$ npm install
> bcrypt#1.0.2 install /Users/me/Documents/Heroku/myapp/node_modules/parse-server/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v72-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bcrypt#1.0.2 and node#12.16.0 (node-v72 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v72-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bcrypt#1.0.2 and node#12.16.0 (node-v72 ABI) (falling back to source compile with node-gyp)
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
sed: ./Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw: No such file or directory
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:321:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
I am trying to set up next.js with express and node.js. The terminal an error when trying to run to local server with express and node. I get the following error when 'npm run dev' is used on the command line.
Package.json:
{
"name": "nextjs",
"description": "NextJS Tutorial",
"version": "1.0.0",
"scripts": {
"dev": "node server/index.js"
},
"dependencies": {
"#zeit/next-sass": "^1.0.1",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-wrap-in-js": "^1.1.1",
"express": "^4.16.4",
"next": "^7.0.2",
"node-sass": "^4.11.0",
"postcss-easy-import": "^3.0.0",
"postcss-loader": "^3.0.0",
"raw-loader": "^1.0.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"sass-loader": "^7.1.0",
"tailwindcss": "^0.7.3"
},
"devDependencies": {
"autoprefixer": "^9.4.5"
}
}
My server/index.js is as follows:
const express = require('express');
const next = require('next');
const PORT = process.env.PORT || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app
.prepare().then(() => {
const server = express();
app.use(bodyParser.json());
server.get('*', (req,res) => {
return handle(req,res);
});
server.listen(PORT, () => {
if (err) throw err;
console.log('> Ready on ${PORT}');
});
})
Error log is as follows:
0 info it worked if it ends with ok
1 verbose cli [ '/Users/hvnwntw8/.nvm/versions/node/v10.14.1/bin/node',
1 verbose cli '/Users/hvnwntw8/.nvm/versions/node/v10.14.1/bin/npm',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm#6.5.0
3 info using node#v10.14.1
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle nextjs#1.0.0~predev: nextjs#1.0.0
6 info lifecycle nextjs#1.0.0~dev: nextjs#1.0.0
7 verbose lifecycle nextjs#1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle nextjs#1.0.0~dev: PATH: /Users/hvnwntw8/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/hvnwntw8/Projects/nextjs/node_modules/.bin:/Users/hvnwntw8/.rbenv/shims:/Users/hvnwntw8/.global-modules/bin:/Users/hvnwntw8/.nvm/versions/node/v10.14.1/bin:/Users/hvnwntw8/anaconda3/bin:/usr/local/opt/python/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mongodb/bin:/opt/yarn-[1.12.3]/bin
9 verbose lifecycle nextjs#1.0.0~dev: CWD: /Users/hvnwntw8/Projects/nextjs
10 silly lifecycle nextjs#1.0.0~dev: Args: [ '-c', 'node sever/index.js' ]
11 silly lifecycle nextjs#1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle nextjs#1.0.0~dev: Failed to exec dev script
13 verbose stack Error: nextjs#1.0.0 dev: `node sever/index.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/hvnwntw8/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (/Users/hvnwntw8/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid nextjs#1.0.0
15 verbose cwd /Users/hvnwntw8/Projects/nextjs
16 verbose Darwin 18.2.0
17 verbose argv "/Users/hvnwntw8/.nvm/versions/node/v10.14.1/bin/node" "/Users/hvnwntw8/.nvm/versions/node/v10.14.1/bin/npm" "run" "dev"
18 verbose node v10.14.1
19 verbose npm v6.5.0
20 error code ELIFECYCLE
21 error errno 1
22 error nextjs#1.0.0 dev: `node sever/index.js`
22 error Exit status 1
23 error Failed at the nextjs#1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I have tried 'npm clean cache -f' followed by 'npm verify', deleting my package-lock.json and node modules folder and running 'npm install' in the terminal. Still no luck. Any help is much appreciated.
Run this command:
npm cache clean --force clean the npm cache
remove node_modules directory
I don't see body-parser in you package.json. install the package
In inext.js when you throw an err, pass the err variable to the function
and it should work.
Your index file:
const express = require('express');
const next = require('next');
const bodyParser = require('body-parser');
const PORT = process.env.PORT || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
const server = express();
app.use(bodyParser.json());
server.get('*', (req, res) => handle(req, res));
server.listen(PORT, err => {
if (err) throw err;
console.log(`> Ready on ${PORT}`);
});
});
I've started a new socket.io project with heroku. The server runs fine locally on windows. I start it with npm start but when I shut it down with ctrl + c I get this error in the console:
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! test1#1.0.0 start: `node index.js`
npm ERR! Exit status 3221225786
npm ERR!
npm ERR! Failed at the test1#1.0.0 start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the test1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs test1
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls test1
npm ERR! There is likely additional logging output above.
I have searched for a solution but the very little I have been able to find has given no solution. I've tried updating npm and node, running npm install again, clearing the npm cache and probably some other actions I can't recall.
Here is my index.js
const express = require('express');
const socketIO = require('socket.io');
const path = require('path');
const PORT = process.env.PORT || 3000;
const server = express()
.use(express.static(__dirname + '/client'))
.listen(PORT, () => console.log(`Listening on ${ PORT }`));
const io = socketIO(server);
const pg = require('pg');
var connectionString = "postgres://jdirjtnfueksiw:823e80fbae9599f0d6797f82342d83bccf1caea764b8a1659356f3ee89r69f94#ec1-78-222-138-451.compute-1.amazonaws.com:5432/jf84jd75jgu26d5?ssl=true";
pg.connect(connectionString, function(err, client, done) {
if (err) {
throw err;
}
else {
console.log('Database connection test successful');
}
});
io.on('connection', function (socket) {
socket.emit('connected');
console.log('New connection from ' + socket.request.connection.remoteAddress);
socket.on('disconnect', function () {
console.log('Player left');
});
});
my package.json
{
"name": "test1",
"version": "1.0.0",
"engines": {
"node": "6.11.4"
},
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"pg": "6.x",
"express": "4.13.4",
"socket.io": "1.4.6"
},
"devDependencies": {},
"description": ""
}
Thank you for any help.
In the index.js can you try putting the following code:
process.on('SIGINT', () => {
process.exit();
});
I think the issue is that Ctrl+C kills the application but there is still some process running in the background. This will ensure that it is terminated.
Hope this helps!
Im doing migration to parse server. And until now everything worked well. But now I want to add google cloud storage file adapter and if I add this line to my code it stops working. Can you somebody tell me why.
var GCSAdapter = require('parse-server-gcs-adapter');
This is the log:
npm ERR! Linux 3.13.0-105-generic
npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! parse-server-example#1.4.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the parse-server-example#1.4.0 start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the parse-server-example package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs parse-server-example
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls parse-server-example
npm ERR! There is likely additional logging output above.
2017-01-29T16:56:58.161879+00:00 app[web.1]:
npm ERR! Please include the following file with any support request:
npm ERR! /app/npm-debug.log
My index.js file:
// Example express application adding the parse-server module to expose Parse
// compatible API routes.
var express = require('express');
var ParseDashboard = require('parse-dashboard');
var ParseServer = require('parse-server').ParseServer;
var GCSAdapter = require('parse-server-gcs-adapter');
var path = require('path');
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
// liveQuery: {
// classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
// }
// filesAdapter: new GCSAdapter(
// "oval-proxy-117311",
// "./SymboloKey",
// "Symbolo",
// {directAccess: true}
// )
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
const dashboard = new ParseDashboard( {
'allowInsecureHTTP': true,
'apps': [
{
'serverURL': process.env.SERVER_URL,
'appName': 'Symbolo',
'appId': process.env.APP_ID,
'masterKey': process.env.MASTER_KEY
}
],
'users': [
{
'user': 'public',
'pass': 'qwerty'
}
]
}, true )
var app = express();
// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);
// serve the Parse Dashboard
app.use('/dashboard', dashboard)
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!');
});
// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});
var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
// This will enable the Live Query real-time server
// ParseServer.createLiveQueryServer(httpServer);
If I run npm install:
Klemens-MBP-2:Cloud klemen$ npm install
npm WARN deprecated mongodb#2.2.10: Please upgrade to 2.2.19 or higher
> bcrypt#1.0.2 install /Users/klemen/Dev/Newcomm/Cloud/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v51-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bcrypt#1.0.2 and node#7.4.0 (node-v51 ABI) (falling back to source compile with node-gyp)
I have an error with Heroku while i try to submit information on my app.
i'm following steps from the documentation : https://trailhead.salesforce.com/en/project/quickstart-heroku-connect/qs-heroku-connect-4
I run the server, i clic on submit button then on my term i get :
{ [Error: connect ETIMEDOUT 54.228.214.47:5432]
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '54.228.214.47',
port: 5432 }
/home/f.freitag/workspace/radiant-dusk-13720/server.js:17
conn.query(
TypeError: Cannot read property 'query' of null
at /home/f.freitag/workspace/radiant-dusk-13720/server.js:17:13
at /home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/pool.js:82:27
at /home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:339:9
at /home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/pool.js:31:28
at null.<anonymous> (/home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/client.js:176:5)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
at Socket.<anonymous> (/home/f.freitag/workspace/radiant-dusk-13720/node_modules/pg/lib/connection.js:59:10)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
npm ERR! Linux 2.6.32-504.12.2.el6.x86_64
npm ERR! argv "/usr/local/node/bin/node" "/usr/local/node/bin/npm" "start"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! code ELIFECYCLE
npm ERR! phone-change#0.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR! Failed at the phone-change#0.0.0 start script 'node server.js'.
npm ERR! This is most likely a problem with the phone-change package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phone-change
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phone-change
npm ERR! There is likely additional logging output above.
I tried to see on google for this problem but i found nothing. Also, i'm not a nodeJS programmer, it's maybe simple.
I didn't change code from the git clone.
Here the code from server.js. I put a comment on the line error
var express = require('express');
var bodyParser = require('body-parser');
var pg = require('pg');
var app = express();
app.set('port', process.env.PORT || 5000);
app.use(express.static('public'));
app.use(bodyParser.json());
app.post('/update', function(req, res) {
pg.connect(process.env.DATABASE_URL, function (err, conn, done) {
if (err) console.log(err);
conn.query( //the error
'UPDATE salesforce.Contact SET Phone = $1, HomePhone = $1, MobilePhone = $1 WHERE LOWER(FirstName) = LOWER($2) AND LOWER(LastName) = LOWER($3) AND LOWER(Email) = LOWER($4)',
[req.body.phone.trim(), req.body.firstName.trim(), req.body.lastName.trim(), req.body.email.trim()],
function(err, result) {
done();
if (err) {
res.status(400).json({error: err.message});
}
else {
res.json(result);
}
});
}
else {
done();
res.json(result);
}
}
);
});
app.listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});
The problem is with the Heroku Connect mappings. Since you've added a new field in the query you also need to update the mappings which you did during the initial setup of Heroku Connect for Contact object.
Steps:
Go to Heroku Connect
Visit mappings section and select the mapping for Contact.
Click on Edit and select HomePhone and save it.
Once above steps are done rerun the application and now should see HomePhone field value populated as same as Phone.