This is the error I got on running npm start:
F:\Works\Projects\Node\Voice_pres_withbackend\api\node_modules\express\lib\router\index.js:458
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
^
TypeError: Router.use() requires a middleware function but got a string
at Function.use (F:\Works\Projects\Node\Voice_pres_withbackend\api\node_modules\express\lib\router\index.js:458:13)
at Function.<anonymous> (F:\Works\Projects\Node\Voice_pres_withbackend\api\node_modules\express\lib\application.js:220:21)
at Array.forEach (<anonymous>)
at Function.use (F:\Works\Projects\Node\Voice_pres_withbackend\api\node_modules\express\lib\application.js:217:7)
at Object.<anonymous> (F:\Works\Projects\Node\Voice_pres_withbackend\api\app.js:25:5)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! api#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the api#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\HP\AppData\Roaming\npm-cache\_logs\2020-09-21T14_50_24_855Z-debug.log
This is part of the code the error is pointing to :
var express = require("express");
var router = express.Router();
router.get("/", function (req, res) {
res.send("Api successful");
});
module.exports = router;
Can you please tell me what it is that I'm doing wrong?
Related
I needed to update backend model, so I entered the npm run update-model command but it returns an error:
events.js:292
throw er; // Unhandled ‘error’ event
^
Error: connect ECONNREFUSED 127.0.0.1:*****
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
Emitted ‘error’ event on ClientRequest instance at:
at Socket.socketErrorListener (_http_client.js:469:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -61,
code: ‘ECONNREFUSED’,
syscall: ‘connect’,
address: ‘127.0.0.1’,
port: ******
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project2 update-model: gen-cuba-front sdk:all --dest src/cuba
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project2 update-model script.
Probably in Studio integration flag isn't turned on.
Use main menu -> File -> Settings -> CUBA -> Enable integration.
I am a newbie and I am trying to run npm run-script watch command and it gives me that error:
Error: ENOENT: no such file or directory, scandir
Log:
> scroller#1.0.0 watch C:\JOB\promocatalog\front
> webpack --mode development --progress --watch
C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:93
throw err;
^
Error: ENOENT: no such file or directory, scandir
at Object.readdirSync (fs.js:974:3)
at Object.<anonymous> (C:\JOB\promocatalog\front\webpack.config.js:26:26)
at Module._compile (C:\JOB\promocatalog\front\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (C:\JOB\promocatalog\front\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
at WEBPACK_OPTIONS (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
at requireConfig (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
at C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
at Array.forEach (<anonymous>)
at module.exports (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\utils\convert-argv.js:121:15)
at C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:71:45
at Object.parse (C:\JOB\promocatalog\front\node_modules\yargs\yargs.js:576:18)
at C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:49:8
at Object.<anonymous> (C:\JOB\promocatalog\front\node_modules\webpack-cli\bin\cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (C:\JOB\promocatalog\front\node_modules\webpack\bin\webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -4058,
syscall: 'scandir',
code: 'ENOENT'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scroller#1.0.0 watch: `webpack --mode development --progress --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scroller#1.0.0 watch 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\Stepa\AppData\Roaming\npm-cache\_logs\2020-07-08T14_34_22_349Z-debug.log
Can anyone help me with this?
I am working at this project https://github.com/ameCont/vue.git
Index.js file:
const fs = require('fs')
const path = require('path')
const Sequelize = require('sequelize')
const config = require('../config/config')
const db = {}
//console.log(config)
const sequelize = new Sequelize(
config.db.database,
config.db.user,
config.db.password,
config.db.options
)
fs
.readdirSync(__dirname)
.filter((file) => {
file !== 'index.js'
}
)
.forEach((file) => {
const model = sequelize.import(path.join(__dirName, file))
db[model.name] = model
})
db.sequelize = sequelize
db.Sequelize = Sequelize
module.exports = db
When I run
npm start
inside server directory I get the error
/home/ubuntu/vue/server/src/models/index.js:10
config.db.database,
^
TypeError: Cannot read property 'database' of undefined
at Object.<anonymous> (/home/ubuntu/vue/server/src/models/index.js:10:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/ubuntu/vue/server/src/app.js:7:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
[nodemon] app crashed - waiting for file changes before starting...
My config.js file contains:
module.exports = {
port: process.env.PORT || 8081,
db: {
database: process.env.DB_NAME || 'vue',
user: process.env.DB_USER || 'vue',
password: process.env.DB_PASS || 'vue',
options: {
dialect: process.env.DIALECT || 'sqlite',
host: process.env.HOST || 'localhost',
storage: 'vue.sqlite.sql'
}
}
}
It has || 'vue' so it shouldn't need a real database (I created one but the issue is the same)
I am beginner with vue.
Here JS: firebase.init error: TypeError: Cannot read property 'database' of undefined, the solution was to install some plugins.
But in my case which plugins?
If it helps, when I run
npm install sqlite3
I get this
> sqlite3#4.2.0 install /home/ubuntu/vue/server/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for sqlite3#4.2.0 and node#10.19.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ubuntu/vue/server/node_modules/sqlite3/build'
gyp ERR! System Linux 5.4.0-26-generic
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "configure" "--fallback-to-build" "--module=/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding/node-v64-linux-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /home/ubuntu/vue/server/node_modules/sqlite3
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/bin/node-gyp configure --fallback-to-build --module=/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding/node-v64-linux-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/ubuntu/vue/server/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 5.4.0-26-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/ubuntu/vue/server/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/ubuntu/vue/server/node_modules/sqlite3
node-pre-gyp ERR! node -v v10.19.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/bin/node-gyp configure --fallback-to-build --module=/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/ubuntu/vue/server/node_modules/sqlite3/lib/binding/node-v64-linux-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
npm WARN eslint-plugin-import#2.20.2 requires a peer of eslint#2.x - 6.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-vue#6.2.2 requires a peer of eslint#^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils#3.17.1 requires a peer of typescript#>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN server#1.0.0 No description
npm WARN server#1.0.0 No repository field.
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.
Also, this topic doesn't help TypeError: Cannot read property 'database' of undefined
because I do have const config = require('../config/config')
Thanks for help!
Actually, in your config you have two exports, so for correctly accessing it you should name the exported objects:
module.exports.config = {
port: process.env.PORT || 8081,
db: {
database: process.env.DB_NAME || 'vue',
user: process.env.DB_USER || 'vue',
password: process.env.DB_PASS || 'vue',
options: {
dialect: process.env.DIALECT || 'sqlite',
host: process.env.HOST || 'localhost',
storage: 'vue.sqlite.sql'
}
}
}
module.exports.otherConfigs = {
// other configs ..
}
Then in model's index.js you import the configs like that:
const { config, otherConfigs } = require('../config/config')
Hi whenever I try to run the npm run dev in the terminal on pet-shop-project tutorial, it comes up with a long list of error here below the error.
hope to solve the issue by your help.
Thanks in advance.
PS C:\pet-shop-tutorial> npm run dev
> pet-shop#1.0.0 dev C:\pet-shop-tutorial
> lite-server
npm : C:\Users\Ali\AppData\Roaming\npm\node_modules\lite-server\lib\lite-server.js:33
At line:1 char:1
+ npm run dev
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (C:\Users\Ali\Ap...te-server.js:33:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
throw (err);
^
SyntaxError: C:\pet-shop-tutorial\bs-config.json: Unexpected token } in JSON at position 70
at JSON.parse (<anonymous>)
at Object.Module._extensions..json (module.js:671:27)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at start (C:\Users\Ali\AppData\Roaming\npm\node_modules\lite-server\lib\lite-server.js:28:17)
at Object.<anonymous> (C:\Users\Ali\AppData\Roaming\npm\node_modules\lite-server\bin\lite-server:7:30)
at Module._compile (module.js:652:30)
npm
ERR!
code
ELIFECYCLE
npm
ERR!
errno
1
npm
ERR!
pet-shop#1.0.0 dev: `lite-server`
npm
ERR!
Exit status 1
npm
ERR!
npm
ERR!
Failed at the pet-shop#1.0.0 dev 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\Ali\AppData\Roaming\npm-cache\_logs\2018-05-30T01_41_54_260Z-debug.log
bs-config-json contents
{
"server": {
"baseDir": ["./src", "./build/contracts"],
}
}
The content of bs-config.json isn't valid JSON. You have an extra comma after the array. It should look like this:
{ "server": { "baseDir": ["./src", "./build/contracts"] } }
That's why you get this error:
SyntaxError: C:\pet-shop-tutorial\bs-config.json: Unexpected token } in JSON at position 70
You can validate your JSON using a JSON validator like https://jsonlint.com/.
I want to use the following framework:
https://github.com/FlorientR/laravel-gentelella
But when I follow the installation guide I need to run the following commands:
php artisan key:generate
npm install --global bower gulp
npm install
bower install
gulp
The first command works fine, but: npm install --global bower gulp fails. It gives the following error:
> C:\Program Files\nodejs\node_modules\npm\node_modules\request\node_modules\har-valid
ator\src\index.js:1
(function (exports, require, module, __filename, __dirname) { ����������������
^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\req
uest\lib\har.js:5:16)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\no
de_modules\\npm\\bin\\npm-cli.js" "install" "--global" "bower" "gulp"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
> npm ERR! C:\Program Files\nodejs\node_modules\npm\node_modules\request\node_modules\
har-validator\src\index.js:1
npm ERR! (function (exports, require, module, __filename, __dirname) { �������������
���
npm ERR! ^
npm ERR! Unexpected token ILLEGAL
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
The package.json contains:
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"laravel-elixir": "^5.0.0",
"bootstrap-sass": "^3.0.0"
}
}
Do you guys see the problem?
I reinstalled NodeJs. That was the problem..