question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"TypeError: Cannot read property 'replace' of undefined" on running the cli `query` command with several SQL statements

See original GitHub issue

Issue type:

[x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [x] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

On running the cli query command with several SQL statements all wrapped with double quotes I receive the following error from the cli-highlight:

> ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli --config ormconfig-migrations.ts "query" "SELECT * FROM folder;
SELECT * FROM sub_folder;"

Running query: SELECT * FROM folder;
SELECT * FROM sub_folder;
Query has been executed. Result: 
Error during query execution:
TypeError: Cannot read property 'replace' of undefined
    at escape (/usr/src/app/node_modules/highlight.js/lib/highlight.js:71:18)
    at Object.highlight (/usr/src/app/node_modules/highlight.js/lib/highlight.js:799:18)
    at Object.highlight (/usr/src/app/node_modules/cli-highlight/src/index.ts:97:21)
    at Function.PlatformTools.highlightJson (/usr/src/app/src/platform/PlatformTools.ts:221:16)
    at Object.<anonymous> (/usr/src/app/src/commands/QueryCommand.ts:55:39)
    at step (/usr/src/app/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
    at Object.next (/usr/src/app/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
    at fulfilled (/usr/src/app/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sindy@1.0.0 typeorm: `ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli --config ormconfig-migrations.ts "query" "SELECT * FROM folder;
npm ERR! SELECT * FROM sub_folder;"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sindy@1.0.0 typeorm 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/2020-08-24T13_13_49_857Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sindy@1.0.0 rls:on: `bash src/policies/enable-rls.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sindy@1.0.0 rls:on 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/2020-08-24T13_13_49_873Z-debug.log

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
nbailliecommented, Dec 2, 2020

Also having this issue, are there any workarounds?

2reactions
xiniriacommented, Dec 1, 2020

I also have this problem, is it possible to re-open the issue?

➜ npm run typeorm query "\"DROP DATABASE IF EXISTS 'air_monitoring';\""

> air-monitoring-backend@0.0.1 typeorm /Users/raphael/Documents/Code/projet-3a/air-monitoring-backend
> node --require ts-node/register ./node_modules/typeorm/cli.js "query" "DROP DATABASE IF EXISTS 'air_monitoring';"

Error during query execution:
TypeError: Cannot read property 'replace' of undefined
    at escapeHTML (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/highlight.js/lib/core.js:53:6)
    at _highlight (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/highlight.js/lib/core.js:1878:18)
    at Object.highlight (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/highlight.js/lib/core.js:1465:7)
    at Object.highlight (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/cli-highlight/src/index.ts:97:21)
    at Function.PlatformTools.highlightSql (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/src/platform/PlatformTools.ts:213:16)
    at Object.<anonymous> (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/src/commands/QueryCommand.ts:56:72)
    at step (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
    at Object.next (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
    at fulfilled (/Users/raphael/Documents/Code/projet-3a/air-monitoring-backend/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'replace' of undefined - Not ...
typescript - TypeError: Cannot read property 'replace' of undefined - Not sure where it's originating as I don't use replace in the repo...
Read more >
[SOLVED] Cannot Read Property 'replace' of Undefined in JS
To fix the “cannot read property 'replace' of undefined” error, perform an undefined check on the variable before calling the replace() method ......
Read more >
Sequelize CLI : cannot read property 'replace' of undefined ...
Coding example for the question Sequelize CLI : cannot read property 'replace' of undefined when migrating DB-sequelize.js.
Read more >
error: cannot read property 'replace' of undefined sequelize
The "Cannot read property 'replace' of undefined" error occurs when calling the `replace()` method on a variable that stores an `undefined` value. To...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error ... A column cannot be assigned more than one value in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found