Hi thank you all in advance.
Can someone please explain to me how to approach this error.
I'm attempting to build my backend of a web application through Heroku and I keep getting the same errors. I have exhausted all options when attempting to figure out my issue.
I'm using Node.js with Knex for querying. Have npm version 6.14.11 & node version v12.12.0
Here are some of my attempts:
I've provided code for the following:
Please let me know if more information is needed. Here is the error I'm getting in Heroku:
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> sqlite3@4.2.0 install /tmp/build_2aff7876_/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module './internal/streams/buffer_list'
Require stack:
- /tmp/build_2aff7876_/node_modules/readable-stream/lib/_stream_readable.js
- /tmp/build_2aff7876_/node_modules/readable-stream/readable.js
- /tmp/build_2aff7876_/node_modules/are-we-there-yet/tracker-stream.js
- /tmp/build_2aff7876_/node_modules/are-we-there-yet/tracker-group.js
- /tmp/build_2aff7876_/node_modules/are-we-there-yet/index.js
- /tmp/build_2aff7876_/node_modules/npmlog/log.js
- /tmp/build_2aff7876_/node_modules/node-pre-gyp/lib/node-pre-gyp.js
- /tmp/build_2aff7876_/node_modules/node-pre-gyp/bin/node-pre-gyp
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/tmp/build_2aff7876_/node_modules/readable-stream/lib/_stream_readable.js:72:18)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/tmp/build_2aff7876_/node_modules/readable-stream/lib/_stream_readable.js',
'/tmp/build_2aff7876_/node_modules/readable-stream/readable.js',
'/tmp/build_2aff7876_/node_modules/are-we-there-yet/tracker-stream.js',
'/tmp/build_2aff7876_/node_modules/are-we-there-yet/tracker-group.js',
'/tmp/build_2aff7876_/node_modules/are-we-there-yet/index.js',
'/tmp/build_2aff7876_/node_modules/npmlog/log.js',
'/tmp/build_2aff7876_/node_modules/node-pre-gyp/lib/node-pre-gyp.js',
'/tmp/build_2aff7876_/node_modules/node-pre-gyp/bin/node-pre-gyp'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@4.2.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@4.2.0 install 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! /tmp/npmcache.E6bjK/_logs/2021-01-28T15_45_17_221Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Here is my package.json:
{
"name": "Reficio_BE",
"version": "1.0.0",
"description": "Backend For Reficio Database",
"main": "index.js",
"scripts": {
"server": "nodemon index.js",
"start": "node index.js",
"test": "cross-env DB_ENV=test jest --watch"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"express": "^4.17.1",
"gitignore": "^0.6.0",
"helmet": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"knex": "^0.21.5",
"knex-cleaner": "^1.3.1",
"moment": "^2.27.0",
"node-pre-gyp": "^0.17.0",
"pg": "^8.3.3",
"sqlite3": "^4.2.0"
},
"devDependencies": {
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"nodemon": "^2.0.7"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hillan1152/Reficio_BE.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/hillan1152/Reficio_BE/issues"
},
"homepage": "https://github.com/hillan1152/Reficio_BE#readme"
}
Here is my Knex file:
// Update with your config settings.
module.exports = {
development: {
client: 'sqlite3',
useNullAsDefault: true,
connection: {
filename: './data/database.db3'
},
migrations: {
directory: './data/migrations'
},
seeds: {
directory:'./data/seeds'
},
pool: {
afterCreate: (conn, done) => {
// runs after a connection is made to the sqlite engine
conn.run('PRAGMA foreign_keys = ON', done); // turn on FK enforcement
}
}
},
testing: {
client: 'sqlite3',
connection: {
filename: './data/test.db3',
},
useNullAsDefault: true,
pool: {
afterCreate: (conn, done) => {
conn.run("PRAGMA foreign_keys = ON", done);
},
},
migrations: {
directory: './data/migrations',
},
seeds: {
directory: './data/seeds',
},
},
production: {
client: 'pg',
connection: process.env.DATABASE_URL,
migrations: {
directory: './data/migrations'
},
seeds: {
directory:'./data/seeds'
},
},
};
Here is my server.js:
// IMPORT DEPENDENCIES
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
// IMPORT ROUTERS
const bookRouter = require('./routers/Book/book_router');
const chapterRouter = require('./routers/chapter/chapter_router');
const jobRouter = require('./routers/Jobs/job_router');
const codeRouter = require('./routers/Code/code_router');
const sectionRouter = require('./routers/Code/section_router');
const jobCodes = require('./routers/Jobs_codes/job_codes_router');
// SETTING UP SERVER
const server = express();
server.use(helmet());
server.use(cors());
server.use(express.json());
// a
// RUN SERVERS
server.use('/api/jobs', jobRouter);
server.use('/api/books', bookRouter);
server.use('/api/chapters', chapterRouter);
server.use('/api/codes', codeRouter);
server.use('/api/sections', sectionRouter);
server.use('/api/jobCodes', jobCodes);
// SET UP BASIC ENDPOINTS
server.get('/', (req, res) => {
res.status(200).json('Server is running!')
});
module.exports = server;
I'm not sure what you're using node-pre-gyp
for, but it doesn't seem like it's configured correctly. You need to add an install
key to your "scripts"
object in your package.json
, as well as a "binary"
key.
From the docs:
"dependencies" : {
"node-pre-gyp": "0.6.x"
},
"devDependencies": {
"aws-sdk": "2.x"
}
"scripts": {
"install": "node-pre-gyp install --fallback-to-build"
},
"binary": {
"module_name": "your_module",
"module_path": "./lib/binding/",
"host": "https://your_module.s3-us-west-1.amazonaws.com"
}
https://www.npmjs.com/package/node-pre-gyp
Maybe that might help get you moving towards the right direction?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.