Sequelize error on npm start - node.js

I'm trying to implement sequelize on my project and when I put
var models = require('../models')
on bin/www, on npm start I get this error:
module.js:471
throw err;
^
Error: Cannot find module 'C:\Users\user\Desktop\projeto\models/..configconfig.json'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\user\Desktop\projeto\models\index.js:8:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\user\Desktop\projeto\bin\www:10:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
npm ERR! Windows_NT 10.0.15063
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.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! projeto#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the projeto#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 projeto 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 information on how to open an issue for this project with:
npm ERR! npm bugs projeto
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls projeto
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\user\Desktop\projeto\npm-debug.log
Besides the default dependencies on a project created with express, I added these:
"pg": "^7.0.2",
"pg-hstore": "^2.3.2",
"sequelize": "^4.4.2",
"sequelize-cli": "^2.7.0"
Obs:
npm install/update didn't solve the problem
reinstall node.js didn't solve the problem
create a new project didn't solve the problem
does anyone have an idea of how to solve this?
thanks a lot!
#Edit
This is my full package.json
{
"name": "projeto",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"sequelize": "^4.4.2",
"sequelize-cli": "^2.7.0",
"pg": "^7.0.2",
"pg-hstore": "^2.3.2",
"body-parser": "~1.17.1",
"cookie-parser": "~1.4.3",
"debug": "~2.6.3",
"ejs": "~2.5.6",
"express": "~4.15.2",
"morgan": "~1.8.1",
"serve-favicon": "~2.4.2"
}
}

In your models index.js file change the following line:
var config = require(__dirname + '/..\config\config.json')[env];
to:
var config = require(__dirname + '/../config/config.json')[env];

Related

saleor salor-dashboard npm start gives errors

I am trying to install the saleor-dashboard latest version(3.7.0), but getting strange errors.
I have done npm start, npm audit fix --force npm install but got the same error and read from a Github page https://github.com/rails/rails/issues/43062#issuecomment-904965034 and a stackoverflow page that the current webpack dev server version is not compatible so I should downgrade it to version 3. I did that as well, but I am still facing the same issue.
The error is:
/root/codes/backend/test/saleor-dashboard/node_modules/webpack-cli/bin/utils/prompt-command.js:46
return func(...args);
^
TypeError: Class constructor ServeCommand cannot be invoked without 'new'
at runWhenInstalled (/root/codes/backend/test/saleor-dashboard/node_modules/webpack-cli/bin/utils/prompt-command.js:46:9)
at promptForInstallation (/root/codes/backend/test/saleor-dashboard/node_modules/webpack-cli/bin/utils/prompt-command.js:140:10)
at /root/codes/backend/test/saleor-dashboard/node_modules/webpack-cli/bin/cli.js:32:43
at Object.<anonymous> (/root/codes/backend/test/saleor-dashboard/node_modules/webpack-cli/bin/cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! saleor-dashboard#3.7.0 start: `npm run build-types && webpack-dev-server -d`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the saleor-dashboard#3.7.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! /root/.npm/_logs/2022-09-03T06_21_34_373Z-debug.log
My package.json includes:
"devDependencies": {
"ts-jest": "^27.0.7",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"typescript": "^4.3.5",
"webpack": "^5.74.0",
"webpack-bundle-analyzer": "^4.4.1",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "3.11.2",
}
Would appreciate a lot if somebody can help me with this.

AWS - EB - Node - Error: Cannot find module '../'

Bcrypt with its dependency node-pre-gyp causes some serious issue when deployed to Elastic Beanstalk.
bcrypt version: 3.0.6
Nodejs version: 8.16 (also same for v.10)
Amazon Linux 4.8.2
bcrypt#3.0.6 install /tmp/deployment/application/node_modules/bcrypt
node-pre-gyp install --fallback-to-build
module.js:550
throw err;
^
Error: Cannot find module '../'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt#3.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt#3.0.6 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/.npm/_logs/2019-08-11T14_06_34_179Z-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v8.15.1-linux-x64/bin/npm
Setting npm config jobs to 1
npm config jobs set to 1
Running npm with --production flag
Failed to run npm install. Snapshot logs for more details.
UTC 2019/08/11 14:06:34 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log
And relevant sections of package.json
"dependencies": {
"axios": "^0.19.0",
"bcrypt": "^3.0.6",
"body-parser": "^1.18.3",
"chai": "^4.2.0",
"express": "^4.16.4",
"firebase": "^5.8.6",
"firebase-admin": "~6.0.0",
"jsonwebtoken": "^8.5.0",
"mocha": "^6.0.2",
"shortid": "^2.2.14"
},
"devDependencies": {
"#babel/cli": "^7.2.3",
"#babel/core": "^7.3.4",
"#babel/polyfill": "^7.2.5",
"#babel/preset-env": "^7.3.4",
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
When deploying to Elastic Beanstalk running Node 8.x, node-gyp doesn't have sufficient permissions to write to the tmp directory. bcrypt won't install and the application deployment will fail.
A workaround is to add a .npmrc file to the root of your project that will force node-gyp to run as root and allow the installation to complete. File contents for .npmrc:
# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm#5 or #6
unsafe-perm=true
pls check this also https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions
Credit goes to this post:
Beanstalk: Node.js deployment - node-gyp fails due to permission denied

Node.js / npm: Can't find module when running in dev mode

When running npm run dev, I got the following error message:
Error: Cannot find module 'webpack/bin/config-yargs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
at Function.Module._load (internal/modules/cjs/loader.js:497:25)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Users\Isabelle\coursetro-eth\node_modules\webpack-dev-server\bin\webpack-dev-server.js:54:1)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! coursetro-eth#1.0.0 dev: `webpack-dev-server --config build/webpack.dev.conf.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the coursetro-eth#1.0.0 dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My enviroment is the following:
OS: Windows 10
NPM: Version 5.6.0
WebPack: Version 4.6
My package.json file:
{
"name":"coursetro-eth",
"version":"1.0.0",
"main":"index.js",
"scripts":{
"dev":"webpack-dev-server --config build/webpack.dev.conf.js",
"publish":"ngc -p tsconfig-aot.json",
"test":"echo \"Error: no test specified\" && exit 1"
},
"author":"",
"license":"ISC",
"description":"",
"dependencies":{
"web3":"github:ethereum/web3.js"
},
"devDependencies":{
"lite-server":"^2.3.0",
"webpack":"^4.6.0",
"webpack-cli":"^2.0.15",
"webpack-dev-server":"^2.11.2",
"webpack-validator":"^2.3.0"
}
}
What is this error about?

TypeError: Cannot read property 'length' of undefined in tsc.js

I have created a nodejs api project using typescript. But I am not able to start it. This is the command I am running
npm start
This is the output of this command
> project1#1.0.0 prestart D:\Workspace
> tsc
D:\Workspace\node_modules\typescript\lib\tsc.js:9921
for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
^
TypeError: Cannot read property 'length' of undefined
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9921:70)
at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
at D:\Workspace\node_modules\typescript\lib\tsc.js:17392:64
at visitNode (D:\Workspace\node_modules\typescript\lib\tsc.js:9533:24)
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9918:25)
at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
at D:\Workspace\node_modules\typescript\lib\tsc.js:17392:64
at visitNodes (D:\Workspace\node_modules\typescript\lib\tsc.js:9542:30)
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9891:24)
at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
at bindChildrenWorker (D:\Workspace\node_modules\typescript\lib\tsc.js:15178:25)
at bindChildren (D:\Workspace\node_modules\typescript\lib\tsc.js:15129:17)
at bindContainer (D:\Workspace\node_modules\typescript\lib\tsc.js:15122:17)
at bind (D:\Workspace\node_modules\typescript\lib\tsc.js:16214:21)
at Object.forEach (D:\Workspace\node_modules\typescript\lib\tsc.js:275:30)
at bindEach (D:\Workspace\node_modules\typescript\lib\tsc.js:15149:20)
at visitNodes (D:\Workspace\node_modules\typescript\lib\tsc.js:9538:24)
at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9707:24)
at bindEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:15165:16)
at bindChildrenWorker (D:\Workspace\node_modules\typescript\lib\tsc.js:15254:21)
at bindChildren (D:\Workspace\node_modules\typescript\lib\tsc.js:15129:17)
at bindContainer (D:\Workspace\node_modules\typescript\lib\tsc.js:15093:17)
at bind (D:\Workspace\node_modules\typescript\lib\tsc.js:16214:21)
at bindSourceFile (D:\Workspace\node_modules\typescript\lib\tsc.js:14851:17)
at Object.bindSourceFile (D:\Workspace\node_modules\typescript\lib\tsc.js:14809:9)
at initializeTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:36496:20)
at Object.createTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:18543:9)
at getDiagnosticsProducingTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:56042:93)
at Object.getGlobalDiagnostics (D:\Workspace\node_modules\typescript\lib\tsc.js:56370:53)
at compileProgram (D:\Workspace\node_modules\typescript\lib\tsc.js:59092:78)
at compile (D:\Workspace\node_modules\typescript\lib\tsc.js:59051:26)
at performCompilation (D:\Workspace\node_modules\typescript\lib\tsc.js:58940:33)
at Object.executeCommandLine (D:\Workspace\node_modules\typescript\lib\tsc.js:58883:9)
at Object.<anonymous> (D:\Workspace\node_modules\typescript\lib\tsc.js:59241:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Workspace\node_modules\typescript\bin\tsc:2:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
npm ERR! Windows_NT 10.0.14393
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.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! project1#1.0.0 prestart: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project1#1.0.0 prestart script 'tsc'.
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 project1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs project1
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls project1
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\Workspace\npm-debug.log
and my package.json
{
"name": "project1",
"version": "1.0.0",
"description": "Project 1",
"main": "index.js",
"scripts": {
"prestart": "tsc",
"start": "concurrently \"tsc --watch \" \"nodemon server.js startServer\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"dependencies": {
"#types/es6-promise": "0.0.32",
"body-parser": "^1.16.0",
"es6-map": "^0.1.5",
"giuseppe": "^1.2.0",
"make-runnable": "^1.0.7",
"request": "^2.79.0",
"request-promise": "^4.1.1",
"typescript": "^2.1.4"
},
"devDependencies": {
"#types/chai": "^3.4.34",
"concurrently": "^3.1.0",
"nodemon": "^1.11.0"
}
}
I have tried deleting node_modules folder and clearing cache using
npm cache clear
and then installing it again using
npm install
but fail to start? what could be the issue?
The issue was with typescript itself. Here is the issue raised on Github
https://github.com/Microsoft/TypeScript/issues/18301
but now the issue has been fixed.
Just update typescript module
npm update typescript --save

Why doesn't npm start run electron app?

I have the following in package.json for several electron apps:
"name": "my-app",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron ."
},
When I'd do npm start in the app folder, the corresponding app use to run. I just started getting the following output for all of my electron apps when using npm start:
electron .
module.js:471
throw err;
^
Error: Cannot find module './'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25).
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/me/electron/my-app/node_modules/.bin/electron:3:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! m1#1.0.0 start: electron .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the m1#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is
likely additional logging output above.
However, I can do either of the following successfully on the command line:
electron main.js
electron .
Anyone know what might have broken the package.json script? Or some other suggestions?
Delete the node_modules folder and then run npm install.

Resources