Cli-highlight, dependency of typeorm, breaks production build
See original GitHub issueDescribe the bug
Launching app fails after build because of an error with cli-highlight
node module which is a dependency of typeorm.
To Reproduce Steps to reproduce the behavior:
- Create electron project using this
npm i typeorm
npm run electron:build
cd
into dist_electron folder and run created app image (or whatever exe or dmg thing it creates on windows/mac)- Get the following error
A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: chalk_1.default.Instance is not a constructor
at Object.<anonymous> (/tmp/.mount_molteoj6HNLv/resources/app.asar/node_modules/cli-highlight/dist/theme.js:12:13)
at Module._compile (internal/modules/cjs/loader.js:786:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
at Module.load (internal/modules/cjs/loader.js:645:32)
at Function.Module._load (internal/modules/cjs/loader.js:560:12)
at Module.require (internal/modules/cjs/loader.js:685:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/tmp/.mount_molteoj6HNLv/resources/app.asar/node_modules/cli-highlight/dist/index.js:19:15)
at Module._compile (internal/modules/cjs/loader.js:786:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
Expected behavior App launches.
Environment (please complete the following information):
- OS and version: Ubuntu 18.04
- node version: 12.6.0
- npm version: 6.14.2
- vue-cli-plugin-electron-builder version : 1.4.6
- electron version: 6.1.9
- other vue plugins used: vuetify, babel, eslint, vuex, router
- custom config for vcp-electron-builder:
module.exports = {
pluginOptions: {
electronBuilder: {
customFileProtocol: './',
externals: [
'sqlite3',
'typeorm',
],
builderOptions: {
extraResources: [
{ from: 'src/worker', to: './worker' }
]
}
}
}
}
Additional context The problem appears to come from here in cli-highlight’s theme.js:
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var chalk_1 = __importStar(require("chalk"));
var chalk = new chalk_1.default.Instance({ level: Math.min(chalk_1.default.level, 1 /* Basic */) });
This is a compiled result of the following:
import { Chalk, default as _chalk, Level } from 'chalk'
const chalk = new _chalk.Instance({ level: Math.min(_chalk.level, Level.Basic) })
What I don’t understand is that this error does not occur on electron:serve
even when I put the same code into background.js, install chalk and console log everything. The constructor works fine.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Cannot run production build - nestjs - Stack Overflow
I am developing API with nestjs and TypeORM connected with PostgreSQL. ... But when I try run production build: npm run prestart:prod ...
Read more >Gitpod Changelog - Latest releases and product updates
A sum-up of Gitpod's latest product improvements, feature releases and community contributions.
Read more >TypeORM - Amazing ORM for TypeScript and JavaScript (ES7 ...
TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be...
Read more >Notices_BigFix_Compliance_V1...
Axlsx helps you create beautiful Office Open XML Spreadsheet documents ( Excel, Google Spreadsheets, Numbers, LibreOffice) without.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I needed to go a bit further than @cooperfrench95’s solution, by elevating
chalk
andcli-highlight
to top level dependencies, and using older versions consistently instead of newer versions.This was because I had other dependencies which also used older versions of chalk, and upgrading them caused cascading new problems, and I gave up at
ts-loader
(https://github.com/TypeStrong/ts-loader/issues/1092).Anyone who cant use
yarn
, you may like to try https://github.com/rogeriochaves/npm-force-resolutions . I had limited success with it before switching to yarn.You shouldn’t need to remove the files, just set the resolution and run yarn. That shows that the problem is with the dependency, not this plugin.