TypeError: Cannot read property 'length' of undefined in tsc.js - node.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

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.

App not deploying with "start node.js" script

I'm trying to deploy a Discord bot with Google Cloud. Whenever I try to deploy using gcloud app deploy, I get this error:
> discord-bot#1.0.0 start /app
> node index.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'discord.js-commando'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/index.js:1:28)
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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-bot#1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-bot#1.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! /root/.npm/_logs/2019-12-09T05_48_58_649Z-debug.log
This is what my package.json looks like:
"name": "discord-bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
"dev": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^11.4.2",
"dotenv": "^7.0.0"
},
"devDependencies": {
"nodemon": "^1.18.11"
}
}
Any help would be greatly appreciated. Thank you!
try install the required package discord.js-commando. It's not in package.json. You can install it with npm install discord.js-commando --save

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?

Error: Cannot find module './util/resolveCommand'

I'm not able to npm start anymore due to a problem with the util npm I think.
I tried to update all the packages and to remove util and re-install it. How could I solve this?
Error: Cannot find module './util/resolveCommand'
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> (/Users/cyruslognonne/Dropbox/C-T-L-K_Master/A_Mandats/A_En cours/LEV/B_Jam/lev_dev/node_modules/cross-spawn/lib/parse.js:3:22)
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! lev_dev#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lev_dev#0.1.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! /Users/cyruslognonne/.npm/_logs/2017-12-03T19_21_25_874Z-debug.log
Here's my package.json.
{
"name": "lev_dev",
"version": "0.1.0",
"private": true,
"dependencies": {
"package.json": "^2.0.1",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-marquee": "^0.1.1",
"react-scripts": "1.0.17",
"react-slick": "^0.15.4",
"slick-carousel": "^1.8.1",
"util": "^0.10.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Thanks, Cyrus
As the error states, the problem is with the cross-spawn module, which is used by react-scripts. The issue is not because of util module.
Try the following to update the dependencies properly and see if it works.
npm install -g npm#latest # to update npm.
rm -rf node_modules # to remove the existing modules.
npm install # to re-install the project dependencies.
You firstly need to
npm clean cache force
and then go to your git bash if you are using windows and run
rm -rf node_modules
and after removing the node_modules then run
npm install

Sequelize error on npm start

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];

Resources