I'm getting npm ERR! code ELIFECYCLE when I try to run my server command
What I'm trying to do is
TensorFlow.js Training in Node.js
It's for college, step 3 says to try out the server I get this
package.json snip
"scripts": {
"start-client": "webpack && webpack-dev-server",
"start-server": "node server.js"
},
error message
C:\xampp\htdocs\leo\baseball>npm run start-server
> tfjs-examples-baseball-node#0.2.0 start-server C:\xampp\htdocs\leo\baseball
> node server.js
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: Não foi possível encontrar o módulo especificado.
\\?\C:\xampp\htdocs\leo\baseball\node_modules\#tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\xampp\htdocs\leo\baseball\node_modules\#tensorflow\tfjs-node\dist\index.js:58:16)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tfjs-examples-baseball-node#0.2.0 start-server: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tfjs-examples-baseball-node#0.2.0 start-server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Usuário\AppData\Roaming\npm-cache\_logs\2020-12-11T07_01_54_120Z-debug.log
server.js
require('#tensorflow/tfjs-node');
const http = require('http');
const socketio = require('socket.io');
const pitch_type = require('./pitch_type');
const TIMEOUT_BETWEEN_EPOCHS_MS = 500;
const PORT = 8001;
// util function to sleep for a given ms
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Main function to start server, perform model training, and emit stats via the socket connection
async function run() {
const port = process.env.PORT || PORT;
const server = http.createServer();
const io = socketio(server);
server.listen(port, () => {
console.log(` > Running socket on port: ${port}`);
});
io.on('connection', (socket) => {
socket.on('predictSample', async (sample) => {
io.emit('predictResult', await pitch_type.predictSample(sample));
});
});
let numTrainingIterations = 10;
for (var i = 0; i < numTrainingIterations; i++) {
console.log(`Training iteration : ${i+1} / ${numTrainingIterations}`);
await pitch_type.model.fitDataset(pitch_type.trainingData, {epochs: 1});
console.log('accuracyPerClass', await pitch_type.evaluate(true));
await sleep(TIMEOUT_BETWEEN_EPOCHS_MS);
}
io.emit('trainingComplete', true);
}
run();
I already tried:
cache clean --force/-f, delete node_modules package-lock.json run npm install
removing package-lock.json and running the server
npm install -g node-pre-gyp
npm install --unsafe-perm
Changing the port from 8001 to 10000 3000 80
running it with every single thing else on my computer closed (this includes my xampp on the bg)
some info
node -v 14.15.1
npm -v 6.14.8
windows 10 x64
My grade needs me to overcome this and finish the tutorial
line 13 of my error accused something wrong at line 58 at this file
at Object.<anonymous> (C:\xampp\htdocs\leo\baseball\node_modules\#tensorflow\tfjs-node\dist\index.js:58:16)
opened the file and commented the line, code ran without problems
Related
I have deployed a simple Nodejs app to Heroku and I keep getting an error in the application logs saying that the module "mongoose" cannot be found. I even provided a relative path instead of just saying require("mongoose"). The deployment succeeds and installs all the dependencies. The source code can be found here https://github.com/collinkleest/trim-io.
Here is the error log from heroku.
2020-10-17T02:01:42.000000+00:00 app[api]: Build started by user collinkleest#gmail.com
2020-10-17T02:01:59.000000+00:00 app[api]: Build succeeded
2020-10-17T02:01:59.493929+00:00 app[api]: Deploy af985be5 by user collinkleest#gmail.com
2020-10-17T02:01:59.493929+00:00 app[api]: Release v14 created by user collinkleest#gmail.com
2020-10-17T02:01:59.652847+00:00 heroku[web.1]: State changed from crashed to starting
2020-10-17T02:02:01.917601+00:00 heroku[web.1]: Starting process with command `npm start`
2020-10-17T02:02:04.175589+00:00 app[web.1]:
2020-10-17T02:02:04.175612+00:00 app[web.1]: > trim-io#0.0.1 start /app
2020-10-17T02:02:04.175612+00:00 app[web.1]: > node server.js
2020-10-17T02:02:04.175613+00:00 app[web.1]:
2020-10-17T02:02:04.369536+00:00 app[web.1]: internal/modules/cjs/loader.js:834
2020-10-17T02:02:04.369538+00:00 app[web.1]: throw err;
2020-10-17T02:02:04.369539+00:00 app[web.1]: ^
2020-10-17T02:02:04.369539+00:00 app[web.1]:
2020-10-17T02:02:04.369539+00:00 app[web.1]: Error: Cannot find module '../node_modules/mongoose'
2020-10-17T02:02:04.369540+00:00 app[web.1]: Require stack:
2020-10-17T02:02:04.369540+00:00 app[web.1]: - /app/models/urlEntity.js
2020-10-17T02:02:04.369541+00:00 app[web.1]: - /app/server.js
2020-10-17T02:02:04.369541+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
2020-10-17T02:02:04.369542+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2020-10-17T02:02:04.369542+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:903:19)
2020-10-17T02:02:04.369543+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-10-17T02:02:04.369543+00:00 app[web.1]: at Object.<anonymous> (/app/models/urlEntity.js:1:18)
2020-10-17T02:02:04.369543+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-10-17T02:02:04.369544+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-10-17T02:02:04.369544+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-10-17T02:02:04.369545+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-10-17T02:02:04.369545+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:903:19) {
2020-10-17T02:02:04.369545+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-10-17T02:02:04.369546+00:00 app[web.1]: requireStack: [ '/app/models/urlEntity.js', '/app/server.js' ]
2020-10-17T02:02:04.369546+00:00 app[web.1]: }
2020-10-17T02:02:04.389361+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-10-17T02:02:04.389827+00:00 app[web.1]: npm ERR! errno 1
2020-10-17T02:02:04.398788+00:00 app[web.1]: npm ERR! trim-io#0.0.1 start: `node server.js`
2020-10-17T02:02:04.399025+00:00 app[web.1]: npm ERR! Exit status 1
2020-10-17T02:02:04.399280+00:00 app[web.1]: npm ERR!
2020-10-17T02:02:04.399493+00:00 app[web.1]: npm ERR! Failed at the trim-io#0.0.1 start script.
2020-10-17T02:02:04.399722+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-10-17T02:02:04.420468+00:00 app[web.1]:
2020-10-17T02:02:04.420707+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-10-17T02:02:04.420857+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-10-17T02_02_04_400Z-debug.log
2020-10-17T02:02:04.487055+00:00 heroku[web.1]: Process exited with status 1
2020-10-17T02:02:04.554273+00:00 heroku[web.1]: State changed from starting to crashed
Here is my server.js for reference as well:
const express = require("express");
const UrlEntity = require("./models/urlEntity");
const mongoose = require("./node_modules/mongoose");
const urlEntity = require("./models/urlEntity");
const app = express();
require('dotenv').config();
const mongoUri = "mongodb+srv://" + process.env.MONGO_USR + ":" + process.env.MONGO_PASS + "#" + process.env.MONGO_URL + "/" + process.env.MONGO_DB + "?retryWrites=true&w=majority";
mongoose.connect(
mongoUri,
{ useNewUrlParser: true, useUnifiedTopology: true}
);
app.use(express.json());
app.use(express.static('public'));
async function checkIdExists(id){
let exists = await UrlEntity.exists({uniqueId: id});
return exists;
}
function generateId(){
let randomId = Math.random().toString(20).substr(2, 8);
while(!(checkIdExists(randomId))){
randomId = Math.random().toString(20).substr(2, 8);
}
return randomId;
}
// redirect functionality
app.get("/:id", async (req, res) => {
if (req.params.id !== null || req.params.id !== undefined){
let doc = await UrlEntity.findOne({uniqueId: req.params.id});
res.redirect(doc.targetUrl);
} else {
res.redirect('/');
}
});
// create new url
app.post("/create-url", async (req, res) => {
console.log("in post");
let id = generateId();
await UrlEntity.create({uniqueId: id,
targetUrl: req.body.url,
dateCreated: req.body.date});
res.send(`${req.protocol}://${req.get('host')}/${id}`);
});
app.listen(process.env.PORT || 5000, () => {console.log("Trim.io API Started")});
You put mongoose in your devDependencies, which will be removed at runtime. (Link from your code) You need to move it to dependencies so that it will be available at runtime.
try changing the const mongoose = require("./node_modules/mongoose")
back to const mongoose = require("mongoose");
Don't forget to set your environment variables MONGO_USR, MONGO_PASS e.t.c on heroku settings. Your server will not start if the environment variable is not set.
Lastly I advice you use a connection string like this mongodb+srv://user:password#cluster2.bftwu.mongodb.net/databaseName
without concatenating
I'm working on backend (Express, Node, Mongo). I set up https with OpenSSL and as required I made changes into bin/www and in app.js. I'm geting very unfamiliar error and very long error. I'm including it here.
E:\CourseraMERN\NodeJS\conFusionServer\node_modules\path-to-regexp\index.js:128
return new RegExp(path, flags);
^
SyntaxError: Invalid regular expression: /^function authenticate(req, res, next) {
if (http\.IncomingMessage\.prototype\.logIn
&& http\.IncomingMessage\.prototype\.logIn !== IncomingMessageExt\.logIn) {
require('\.\.\/framework\/connect')\.__monkeypatchNode();
}
\/\/ accumulator for failures from each strategy in the chain
var failures = [];
function allFailed() {
if (callback) {
if (!multi) {
return callback(null, false, failures[0]\.challenge, failures[0]\.status);
} else {
var challenges = failures\.map(function(f) { return f\.challenge; });
var statuses = failures\.map(function(f) { return f\.status; });
return callback(null, false, challenges, statuses);
}
}
..................................................................
..................................................................
..................................................................
at new RegExp (<anonymous>)
at pathtoRegexp (E:\CourseraMERN\NodeJS\conFusionServer\node_modules\path-to-regexp\index.js:128:10)
at new Layer (E:\CourseraMERN\NodeJS\conFusionServer\node_modules\express\lib\router\layer.js:45:17)
at Function.route (E:\CourseraMERN\NodeJS\conFusionServer\node_modules\express\lib\router\index.js:494:15)
at Function.proto.<computed> [as get] (E:\CourseraMERN\NodeJS\conFusionServer\node_modules\express\lib\router\index.js:509:22)
**at Object.<anonymous> (E:\CourseraMERN\NodeJS\conFusionServer\routes\users.js:12:8)**
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
**at Object.<anonymous> (E:\CourseraMERN\NodeJS\conFusionServer\app.js:13:19)**
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! confusionserver#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusionserver#0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Lenovo\AppData\Roaming\npm-cache\_logs\2020-09-07T04_31_33_225Z-debug.log
users.js line 12:
router.get( authenticate.verifyUser, authenticate.verifyAdmin, '/', function(req, res, next) {
User.find({})
.then((users) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.json(users);
}, (err) => next(err))
.catch((err) => next(err));
});
app.js line 13:
var usersRouter = require('./routes/users');
So, where am I missing? Why I'm getting that error? Before changing the code for OpenSSL everything was working fine and now this.
My Node version is: v12.18.1, express: 4.16.1, npm: 6.14.8
The path argument for router.get() has to come first.
Change this:
router.get( authenticate.verifyUser, authenticate.verifyAdmin, '/', ...)
to this:
router.get('/', authenticate.verifyUser, authenticate.verifyAdmin, ...)
The error is attempting to show that you're passing authenticate.verifyUser where Express expects either a string or a regex, but you're passing a function.
FYI, this is an interesting example for where TypeScript could be helpful. This could have been a compile error about a wrong argument type for the first argument, instead of a cryptic run-time error.
From the Express doc, the signature for app.get() is this:
app.get(path, callback [, callback ...])
The path must be first followed by one or more callbacks.
I have installed Parse Server on Heroku and forked the Parse Server Example. When I git push heroku master I get the error
"You must provide an appIp!"
Error log:
019-03-20T11:03:56.517489+00:00 heroku[web.1]: Starting process with command `npm start`
2019-03-20T11:03:59.418738+00:00 app[web.1]:
2019-03-20T11:03:59.418754+00:00 app[web.1]: > parse-server-example#1.4.0 start /app
2019-03-20T11:03:59.418756+00:00 app[web.1]: > node index.js
2019-03-20T11:03:59.418757+00:00 app[web.1]:
2019-03-20T11:04:01.887096+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-20T11:04:01.724008+00:00 app[web.1]:
2019-03-20T11:04:01.724030+00:00 app[web.1]: /app/node_modules/parse-server/lib/ParseServer.js:218
2019-03-20T11:04:01.724032+00:00 app[web.1]: throw err;
2019-03-20T11:04:01.724033+00:00 app[web.1]: ^
2019-03-20T11:04:01.724105+00:00 app[web.1]: You must provide an appId!
2019-03-20T11:04:01.779713+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-03-20T11:04:01.780520+00:00 app[web.1]: npm ERR! errno 7
2019-03-20T11:04:01.782955+00:00 app[web.1]: npm ERR! parse-server-example#1.4.0 start: `node index.js`
2019-03-20T11:04:01.783173+00:00 app[web.1]: npm ERR! Exit status 7
2019-03-20T11:04:01.783716+00:00 app[web.1]: npm ERR!
2019-03-20T11:04:01.783983+00:00 app[web.1]: npm ERR! Failed at the parse-server-example#1.4.0 start script.
2019-03-20T11:04:01.784194+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-03-20T11:04:01.804701+00:00 app[web.1]:
2019-03-20T11:04:01.805007+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-03-20T11:04:01.805196+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-03-20T11_04_01_786Z-debug.log
2019-03-20T11:04:01.866235+00:00 heroku[web.1]: Process exited with status 7
index.js:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
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://key
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey',
serverURL: process.env.SERVER_URL || 'http://myApp.herokuapp.com/parse',
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
var server = ParseServer({
verifyUserEmails: true,
publicServerURL: 'myApp.herokuapp.com/parse',
appName: 'myAppName',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'parse#example.com',
domain: 'domainFromMailGun.mailgun.org',
apiKey: 'myAPIKey',
}
}
});
I have provided the appId in appId: process.env.APP_ID || 'myAppId', or am I missing something here? Does the appId have to provided elsewhere?
First of all, please invalidate those MongoDB credentials immediately. They are forever compromised, and you need to generate new ones. Editing them out of your question is not enough.
I'm not totally clear on what you're trying to do here, but you're actually instantiating two Parse servers. You do provide an appId for the first one (api), but not for the second (server).
You probably only need one Parse Server. If you do actually need two for some reason, each one will need an appId.
I have used below code snippet for google speech to text recognition,
var speech = require('google-speech-api');
var opts = {
file: 'speech.mp3',
key: '<Google API Key>'
};
speech(opts, function (err, results) {
console.log(results);
// [{result: [{alternative: [{transcript: '...'}]}]}]
});
Then I tried to do
"npm install google-speech-api"
from command prompt. It's giving error.
Then, I did
"npm install googleapis"
and it succeeded.
I executed the Node.js script from command prompt "node myspeech.js"...it's throwing error as,
module.js:341
throw err;
^
Error: Cannot find module 'google-speech-api'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\myspeechtest.js:1:76)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
As you can see in your error logs:
npm ERR! code ENOGIT
npm ERR! not found: git npm
ERR! npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.
You need to have git installed on your system, and in your PATH.
For Windows, you can use git-bash, for Debian/Ubuntu, a simple sudo apt-get install git should do the tricks.
const projectId = 'yourGoogleProjectId';
let file="conf.json"//google exported this for you
var speech = require('#google-cloud/speech')({
projectId: projectId,
keyFilename: file
});
const fs = require('fs');
const fileName = 'yourMp3FilePath';
// Reads a local audio file and converts it to base64
const fileMp3 = fs.readFileSync(fileName);
const audioBytes = fileMp3.toString('base64');
const audio = {
content:audioBytes
};
const config = {
encoding: 'AMR_WB',
sampleRateHertz: 16000,
languageCode: 'en-US'
};
const request = {
audio: audio,
config: config
};
speech.recognize(request)
.then((results) => {
const transcription = results[0].results[0].alternatives[0].transcript;
console.log(`Transcription: `, transcription);
})
.catch((err) => {
console.error('ERROR:', err);
});
I am trying to get data onto a web page from an sqlite3 database in my Express app I have following in my route file
var express = require('express');
var router = express.Router();
var fs = require("fs");
var file = "./database/testDB.db";
var exists = fs.existsSync(file);
var sqlite3 = require("sqlite3").verbose();
var db = new sqlite3.Database(file);
/* GET home page. */
router.get('/', function(req, res, next) {
if (exists){
console.log('DB File Exists!!!!');
}
var data = 'Data Starts';
db.serialize(function() {
db.each("SELECT id, as_nr, as_name FROM Autonomous_systems", function(err, row) {
console.log(+row.id+": "+row.as_nr);
//data+= '--'+row.as_name + ": " + row.as_nr;
});
});
db.close();
console.log(data);
res.render('index', { title: 'Express', datax: data });
});
module.exports = router;
When I load the page in browser I get the page for the first time and the rows printed on console.
but when I reload the page I get following error
> sqliteTest#0.0.0 start /home/ehsan/n_ode/Tutorials/sqliteTest
> node ./bin/www
DB File Exists!!!!
Data Starts
29: 25648/53265
30: 5555
31: 5559
35: 98789
36: 98789
GET / 304 80.428 ms - -
GET /stylesheets/style.css 304 3.021 ms - -
At reload
DB File Exists!!!!
/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/sqlite3/lib/trace.js:28
throw err;
^
TypeError: Cannot read property 'id' of undefined
at /home/ehsan/n_ode/Tutorials/sqliteTest/routes/index.js:21:23
at Database.errBack (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/sqlite3/lib/sqlite3.js:16:21)
at Database.<anonymous> (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/sqlite3/lib/sqlite3.js:20:25)
at Database.<anonymous> (/home/ehsan/n_ode/Tutorials/sqliteTest/routes/index.js:20:8)
at /home/ehsan/n_ode/Tutorials/sqliteTest/routes/index.js:19:5
at Layer.handle [as handle_request] (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/layer.js:95:5)
at next (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/route.js:112:3)
--> in Database#each('SELECT id, as_nr, as_name FROM Autonomous_systems', [Function])
at Database.<anonymous> (/home/ehsan/n_ode/Tutorials/sqliteTest/routes/index.js:20:8)
at /home/ehsan/n_ode/Tutorials/sqliteTest/routes/index.js:19:5
at Layer.handle [as handle_request] (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/layer.js:95:5)
at next (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/layer.js:95:5)
at /home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/index.js:330:12)
at next (/home/ehsan/n_ode/Tutorials/sqliteTest/node_modules/express/lib/router/index.js:271:10)
npm ERR! Linux 3.16.0-60-generic
npm ERR! argv "/home/ehsan/.nvm/versions/node/v4.2.4/bin/node" "/home/ehsan/.nvm/versions/node/v4.2.4/bin/npm" "start"
npm ERR! node v4.2.4
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! sqliteTest#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqliteTest#0.0.0 start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the sqliteTest 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 sqliteTest
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/ehsan/n_ode/Tutorials/sqliteTest/npm-debug.log
The Problem was that I had declared
var db = new sqlite3.Database(file);
globally in my route
while calling db.close(); after using and querying it once
once the db is closed the subsequent queries return undefined
moving var db = new sqlite3.Database(file); inside the get method of the route opens a connection at every access