NestJS Logger Doesn't Print on Windows - javascript

I am using the NestJS starter from their documentation here.
NestJS 7.6.15.
Node Version 12.20.1
Windows 10 Pro (OS Build 19042.867)
I did not change anything in the main.ts to change the logger functionality.
main.ts:
import { NestFactory } from '#nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
None of my loggers are printing anything at all. Example:
import { Injectable, Logger } from '#nestjs/common';
import { Cron, CronExpression } from '#nestjs/schedule';
#Injectable()
export class ScheduledTask {
private readonly logger = new Logger(ScheduledTask.name);
#Cron(CronExpression.EVERY_5_SECONDS)
handleCron() {
this.logger.log('This does not print.');
}
}
package.json
{
"name": "nest-typescript-starter",
"private": true,
"version": "1.0.0",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^7.6.15",
"#nestjs/core": "^7.6.15",
"#nestjs/mapped-types": "*",
"#nestjs/platform-express": "^7.6.15",
"#nestjs/schedule": "^0.4.3",
"#nestjs/typeorm": "^7.1.5",
"mysql2": "^2.2.5",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.6",
"typeorm": "^0.2.31"
},
"devDependencies": {
"#nestjs/cli": "^7.6.0",
"#nestjs/schematics": "^7.3.1",
"#nestjs/testing": "^7.6.15",
"#types/cron": "^1.7.2",
"#types/express": "^4.17.11",
"#types/jest": "^26.0.22",
"#types/node": "^14.14.36",
"#types/supertest": "^2.0.10",
"#typescript-eslint/eslint-plugin": "^4.19.0",
"#typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"supertest": "^6.1.3",
"ts-jest": "^26.5.4",
"ts-loader": "^8.0.18",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
Any ideas?

It looks like NestJS doesn't automatically rebuild my dist folder. Once I deleted that manually it forced a rebuild and the logs started displaying. Seems like I need to do this every time I change code.

Related

Invalid package name "#" of package "##nestjs/passport": name can only contain URL-friendly characters

Creates a Module Federation applcation, API server, but when I running command npm install I am getting error. My node version is v16.17.1 and npm version is 8.19.2
╰─ npx create-mf-app ─╯
? Pick the name of your app: server
? Project Type: API Server
? Port number: 8080
? Template: nestjs-auth
Your 'server' project is ready to go.
Next steps:
▶️ cd server
▶️ npm install
▶️ npm start
Error:
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "#" of package "##nestjs/passport": name can only contain URL-friendly characters.
Package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#": "nestjs/passport",
"#nestjs/common": "^8.0.0",
"#nestjs/core": "^8.0.0",
"#nestjs/jwt": "^8.0.0",
"#nestjs/passport": "^8.0.1",
"#nestjs/platform-express": "^8.0.0",
"#nestjs/serve-static": "^2.2.2",
"class-validator": "^0.13.1",
"jsonwebtoken": "^8.5.1",
"passport": "^0.5.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
},
"devDependencies": {
"#nestjs/cli": "^8.0.0",
"#nestjs/schematics": "^8.0.0",
"#nestjs/testing": "^8.0.0",
"#types/express": "^4.17.13",
"#types/jest": "^27.0.1",
"#types/node": "^16.0.0",
"#types/passport-jwt": "^3.0.6",
"#types/passport-local": "^1.0.34",
"#types/supertest": "^2.0.11",
"#typescript-eslint/eslint-plugin": "^4.28.2",
"#typescript-eslint/parser": "^4.28.2",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^27.0.6",
"prettier": "^2.3.2",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
So as Micael Levi suggested I removed the "#": "nestjs/passport", entry from package.json and deleted package-lock.json file and run command npm install. It resolved the error.

Getting error 'Support for the experimental syntax 'jsx' isn't currently enabled' when running npm run start

I am currently receiving this error when running npm run start from my terminal 'Support for the experimental syntax 'jsx' isn't currently enabled'. Im not sure what the issue is as my babel.config.js seems to have the correct presets and plugins to ensure everything works correctly. Any help would be appreciated.
I am running a windows machine and my babel.config is in the route of my project as is my package.json.
Package.json:
{
"name": "ct-universal-app",
"version": "2.124.0",
"description": "The Culture Trip Universal React App",
"engines": {
"node": "=14.16.1",
"npm": "=6.14.12"
},
"scripts": {
"start": " SET NODE_ENV=production && SET TCT_ENV=production && node server.js",
"prod": "cross-env NODE_ENV=development TCT_ENV=production node server.js",
"dev": "cross-env NODE_ENV=development TCT_ENV=dev node server.js",
"staging": "NODE_ENV=production TCT_ENV=staging node server.js",
"dev-staging": "cross-env NODE_ENV=development TCT_ENV=staging node server.js",
"local": "cross-env NODE_ENV=development TCT_ENV=local node server.js",
"base-prettier": "prettier --ignore-path .gitignore",
"base-eslint": "eslint --ignore-path .gitignore --rule \"no-console: 1\"",
"lint-eslint-config-prettier": "eslint --print-config .eslintrc | eslint-config-prettier-check",
"lintjs": "npm run base-eslint -- --max-warnings 0 \"**/*.js\" \"**/*.ts?(x)\" .circleci .eslintplugin",
"format": "npm run lintfix && npm run prettierWrite",
"lintfix": "npm run base-eslint -- --fix \"**/*.js\" \"**/*.ts?(x)\"",
"prettierWrite": "npm run base-prettier -- --write \"**/*.js\" \"**/*.ts?(x)\"",
"ts-compile-check": "tsc -p tsconfig.json --noEmit",
"build": "next build",
"bundleAnalyze": "cross-env BUNDLE_ANALYZE=true next build",
"test": "cross-env BABEL_ENV=test node --max-old-space-size=4096 --expose-gc node_modules/jest/bin/jest.js --logHeapUsage --verbose --coverage",
"test-dev": "BABEL_ENV=test npx jest --watch",
"lighthouse-test": "npx jest --config='.circleci/jest.config.js'",
"e2e-smoke-desktop-test": "cross-env NODE_ENV=development TCT_ENV=staging BABEL_ENV=e2e-test npx wdio ./tests/config/e2e-test-desktop.conf.js --suite smoke",
"e2e-sanity-desktop-test": "cross-env NODE_ENV=development TCT_ENV=staging BABEL_ENV=e2e-test npx wdio ./tests/config/e2e-test-desktop.conf.js --suite sanity",
"e2e-regression-desktop-test": "cross-env NODE_ENV=development TCT_ENV=staging BABEL_ENV=e2e-test npx wdio ./tests/config/e2e-test-desktop.conf.js --suite regression --suite sanity --suite smoke",
"e2e-smoke-mobile-web-test": "cross-env NODE_ENV=development TCT_ENV=staging BABEL_ENV=e2e-test npx wdio ./tests/config/e2e-test-mobile.conf.js --suite smoke",
"e2e-sanity-mobile-web-test": "cross-env NODE_ENV=development TCT_ENV=staging BABEL_ENV=e2e-test npx wdio ./tests/config/e2e-test-mobile.conf.js --suite sanity",
"e2e-regression-mobile-web-test": "cross-env NODE_ENV=development TCT_ENV=staging BABEL_ENV=e2e-test npx wdio ./tests/config/e2e-test-mobile.conf.js --suite smoke",
"allure": "node_modules/.bin/allure generate ./tests/reports/allure-results -c && allure open || true",
"mock": "nodemon ./mock/index.js localhost 7001 & NODE_ENV=development TCT_ENV=test node server.js",
"ui-test": "NODE_ENV=development TCT_ENV=test BABEL_ENV=e2e-test npx wdio ./tests/config/ui-test.conf.js",
"cy:open": "cypress open"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "branch-naming-check \"^feature/WFE-[0-9]+.*$\" && npm run ts-compile-check && npm run lintjs"
}
},
"lint-staged": {
"*.{js,ts,tsx}": [
"npm run base-eslint -- --fix --max-warnings 0",
"npm run base-prettier -- --write",
"git add"
]
},
"keywords": [],
"author": "Culture Trip (Israel) Ltd.",
"license": "TCT",
"sideEffects": [
"./node_modules/isomorphic-fetch/fetch-bower.js",
"./node_modules/isomorphic-fetch/fetch-npm-browserify.js",
"./node_modules/isomorphic-fetch/fetch-npm-node.js",
"./node_modules/es6-promise/lib/es6-promise.js"
],
"dependencies": {
"#apollo/client": "^3.3.11",
"#babel/plugin-proposal-class-properties": "7.8.3",
"#culture-trip/bookable-ui-module": "^5.4.0",
"#culture-trip/culturetrip-ui": "^32.3.8",
"#culture-trip/experiments-component": "^14.1.21",
"#culture-trip/frontend-utils-module": "2.7.0",
"#culture-trip/header-ui-module": "8.12.42",
"#culture-trip/jwplayer-module": "^1.7.4",
"#culture-trip/login-signup-module": "2.3.7",
"#culture-trip/tile-ui-module": "^1.12.4",
"#culture-trip/topic-hub-ui-module": "^3.14.5",
"#culture-trip/tracking-ui-module": "^2.2.7",
"#culture-trip/wishlist-ui-module": "^1.7.5",
"body-parser": "1.18.2",
"branch-sdk": "2.49.0",
"columbus-module": "github:culture-trip/columbus-module#v1.9.0",
"compression": "1.7.3",
"cookie-parser": "1.4.3",
"crypto-hash": "^1.3.0",
"datadog-node-utils": "git+ssh://git#github.com/culture-trip/datadog-node-utils.git#v5",
"date-fns": "^2.19.0",
"es6-promise": "4.1.0",
"express": "4.16.4",
"fast-geoip": "^1.1.23",
"graphql": "^15.5.0",
"helmet": "3.21.2",
"intersection-observer": "^0.11.0",
"isomorphic-fetch": "2.2.1",
"jwt-decode": "2.2.0",
"lodash": "^4.17.21",
"mobile-detect": "1.3.6",
"mobx": "5.14.2",
"mobx-react": "6.1.4",
"next": "^10.1.3",
"next-router-events": "1.0.1",
"next-transpile-modules": "2.3.1",
"passport": "0.4.0",
"passport-facebook": "2.1.1",
"passport-google-oauth": "1.0.0",
"react": "^17.0.2",
"react-dfp": "github:nirarazi/react-dfp",
"react-dom": "^17.0.2",
"react-html-parser": "2.0.2",
"react-loading-animation": "1.3.0",
"react-no-ssr": "1.1.0",
"react-swipe": "6.0.4",
"react-visibility-sensor": "5.1.1",
"smoothscroll-polyfill": "0.4.3",
"styled-components": "^5.2.1",
"universal-cookie": "2.0.8",
"uuid": "3.3.2",
"web-vitals": "^0.2.4"
},
"devDependencies": {
"#babel/core": "7.8.6",
"#babel/plugin-proposal-decorators": "7.0.0",
"#babel/plugin-proposal-numeric-separator": "7.8.3",
"#babel/plugin-proposal-object-rest-spread": "7.8.3",
"#babel/plugin-syntax-dynamic-import": "7.8.3",
"#babel/plugin-transform-modules-commonjs": "7.8.3",
"#babel/plugin-transform-runtime": "7.8.3",
"#babel/preset-env": "7.9.0",
"#babel/preset-react": "7.8.3",
"#babel/preset-typescript": "7.8.3",
"#babel/register": "^7.13.8",
"#innocells/branch-naming-check": "1.0.0",
"#testing-library/react": "11.1.0",
"#testing-library/react-hooks": "3.2.1",
"#types/chance": "^1.1.3",
"#types/enzyme": "3.10.5",
"#types/jest": "25.1.3",
"#types/node": "^13.13.45",
"#types/react": "^17.0.3",
"#types/react-dom": "^17.0.3",
"#types/styled-components": "^5.1.7",
"#typescript-eslint/eslint-plugin": "^2.34.0",
"#typescript-eslint/parser": "^2.34.0",
"#wdio/allure-reporter": "5.18.6",
"#wdio/browserstack-service": "^5.22.1",
"#wdio/cli": "5.18.4",
"#wdio/devtools-service": "5.16.16",
"#wdio/dot-reporter": "5.18.6",
"#wdio/junit-reporter": "5.18.6",
"#wdio/local-runner": "5.18.4",
"#wdio/mocha-framework": "5.18.6",
"#wdio/selenium-standalone-service": "5.16.10",
"#wdio/spec-reporter": "5.18.6",
"#wdio/sync": "5.18.6",
"#zeit/next-bundle-analyzer": "0.1.2",
"#zeit/next-css": "1.0.1",
"amphtml-validator": "^1.0.35",
"babel-eslint": "8.2.1",
"babel-jest": "25.1.0",
"babel-loader": "8.0.6",
"babel-plugin-dynamic-import-node": "2.2.0",
"babel-plugin-styled-components": "^1.12.0",
"babel-runtime": "6.23.0",
"brotli-gzip-webpack-plugin": "0.5.0",
"chai": "^4.3.3",
"chance": "^1.1.7",
"chrome-launcher": "^0.13.4",
"chromedriver": "2.45.0",
"cors": "2.8.5",
"cross-env": "4.0.0",
"cypress": "7.5.0",
"enzyme": "3.10.0",
"#wojtekmaj/enzyme-adapter-react-17": "0.6.3",
"enzyme-to-json": "3.4.3",
"eslint": "5.9.0",
"eslint-config-prettier": "6.0.0",
"eslint-config-react": "1.1.7",
"eslint-find-rules": "3.3.1",
"eslint-loader": "2.0.0",
"eslint-plugin-babel": "5.1.0",
"eslint-plugin-cypress": "^2.11.3",
"eslint-plugin-local": "1.0.0",
"eslint-plugin-react": "7.10.0",
"eslint-plugin-react-hooks": "2.3.0",
"eslint-plugin-wdio": "5.7.0",
"faker": "4.1.0",
"husky": "^4.2.1",
"ignore-loader": "0.1.2",
"jest": "^26.6.3",
"jest-fetch-mock": "2.1.2",
"jest-styled-components": "^7.0.3",
"lighthouse": "^6.5.0",
"lint-staged": "9.2.1",
"mocha": "6.2.2",
"mock-req-res": "1.0.2",
"nodemon": "^2.0.7",
"prettier": "1.19.0",
"prop-types": "15.7.2",
"react-test-renderer": "17.0.2",
"sinon": "7.2.2",
"style-loader": "0.17.0",
"typescript": "3.8.3",
"wdio-browserstack-reporter": "github:browserstack/wdio-browserstack-reporter#wdio5",
"webdriverio": "5.18.4",
"webpack-bundle-analyzer": "3.3.2"
}
}
Babel.config.js:
const environment = process.env['BABEL_ENV'] || process.env['NODE_ENV'];
const presets = [];
const plugins = [];
if (environment === 'development') {
presets.push('next/babel');
plugins.push(
['#babel/plugin-proposal-decorators', { legacy: true }],
['#babel/plugin-proposal-class-properties', { loose: true }],
['styled-components', { ssr: true, displayName: true, preprocess: false }]
);
}
if (environment === 'production') {
presets.push(['next/babel', '#babel/preset-env', '#babel/preset-react']);
plugins.push(
['#babel/plugin-proposal-decorators', { legacy: true }],
['#babel/plugin-proposal-class-properties', { loose: true }],
['styled-components', { ssr: true, displayName: true, preprocess: false }]
);
}
if (environment === 'test') {
presets.push('#babel/preset-env', '#babel/preset-react', '#babel/preset-typescript');
plugins.push(
['#babel/plugin-proposal-decorators', { legacy: true }],
['#babel/plugin-proposal-class-properties', { loose: true }],
['#babel/plugin-transform-runtime'],
['#babel/plugin-syntax-dynamic-import'],
['#babel/plugin-proposal-object-rest-spread'],
['styled-components', { ssr: false, displayName: false, preprocess: false }]
);
}
if (environment === 'e2e-test') {
presets.push([
'#babel/preset-env',
{
targets: {
node: 8
}
}
]);
plugins.push(
['#babel/plugin-proposal-decorators', { legacy: true }],
['#babel/plugin-proposal-class-properties', { loose: true }]
);
}
module.exports = { presets, plugins };

Commitizen and husky seem to be triggering the pre-commit hook twice

I am trying to configure commitizen with husky and when I commit using a custom script from package.json commit gets triggered twice. This is not the case when I try to run git commit though.
Opened the issue on github but if anyone knows any workaround for this that would be great
Github Issue: https://github.com/commitizen/cz-cli/issues/844
Below is the package.json
{
"scripts": {
"cz": "cz",
"dev": "nodemon --watch '**/*.ts' --exec 'ts-node' src/server.ts",
"lint": "eslint . --ext .ts",
"lint-and-format": "eslint . --ext .ts --fix",
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"test": "echo \"Error: no test specified\" && exit 1",
"prepare": "husky install",
"build": "tsc",
"start": "NODE_ENV=production yarn build && node dist/server.js"
},
"lint-staged": {
"src/**/*.ts": [
"yarn prettier-format",
"yarn lint-and-format"
],
"*.ts": "eslint --cache --fix"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"#types/express": "^4.17.13",
"#typescript-eslint/eslint-plugin": "^4.29.1",
"#typescript-eslint/parser": "^4.29.1",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"lint-staged": ">=10",
"nodemon": "^2.0.12",
"prettier": "^2.3.2",
"ts-node": "^10.2.0",
"typescript": "^4.3.5",
"husky": ">=6"
}
}

NestJS CLI project running error on terminal

An error showing on running the command yarn start:dev on my webstorm built-in terminal
Error Screenshot
Here is my package.json file
{
"name": "test-project",
"version": "0.0.1",
"description": "",
"author": "",
"license": "MIT",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nodemon",
"start:debug": "nodemon --config nodemon-debug.json",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^6.10.14",
"#nestjs/core": "^6.10.14",
"#nestjs/platform-express": "^6.10.14",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"rxjs": "^6.5.4",
"uuid": "^7.0.2"
},
"devDependencies": {
"#nestjs/cli": "^6.13.2",
"#nestjs/schematics": "^6.8.1",
"#nestjs/testing": "^6.10.14",
"#types/express": "^4.17.2",
"#types/jest": "25.1.2",
"#types/node": "^13.1.6",
"#types/supertest": "^2.0.8",
"#typescript-eslint/eslint-plugin": "^2.12.0",
"#typescript-eslint/parser": "^2.12.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.19.1",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "25.2.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.6.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.7.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
I'm trying to solve but I couldn't figure out the code!
Happens when the nodemon process abruptly ends / close the terminal. Normally end up using a different port number or restart the system. You can kill the nodemon process running on port 3000 by running the following command:
kill -9 $(lsof -t -i:3000)

Monaco Editor: Cannot find module 'monaco-editor' but it's installed

I'm making a desktop application using electron and I decided to use Monaco Editor and install it using npm install monaco-editor but when I run the application it says Cannot find module 'monaco-editor'
I used electron-react-boilerplate as a boilerplate.
I tried both methods for installing it using ESM
This is my package.json:
{
"name": "electron-react-boilerplate",
"productName": "ElectronReact",
"version": "0.17.1",
"description": "Electron application boilerplate based on React, React Router, Webpack, React Hot Loader for rapid application development",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
"build-dll": "cross-env NODE_ENV=development webpack --config ./configs/webpack.config.renderer.dev.dll.babel.js --colors",
"build-e2e": "cross-env E2E_BUILD=true yarn build",
"build-main": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.main.prod.babel.js --colors",
"build-renderer": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.renderer.prod.babel.js --colors",
"dev": "cross-env START_HOT=1 node -r #babel/register ./internals/scripts/CheckPortInUse.js && cross-env START_HOT=1 yarn start-renderer-dev",
"flow": "flow",
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true",
"lint": "cross-env NODE_ENV=development eslint --cache --format=pretty .",
"lint-fix": "yarn --silent lint --fix; exit 0",
"lint-styles": "stylelint --ignore-path .eslintignore '**/*.*(css|scss)' --syntax scss",
"lint-styles-fix": "yarn --silent lint-styles --fix; exit 0",
"package": "yarn build && electron-builder build --publish never",
"package-all": "yarn build && electron-builder build -mwl",
"package-ci": "yarn postinstall && yarn build && electron-builder --publish always",
"package-linux": "yarn build && electron-builder build --linux",
"package-win": "yarn build && electron-builder build --win --x64",
"postinstall": "yarn flow-typed && electron-builder install-app-deps package.json && yarn build-dll && opencollective-postinstall",
"postlint-fix": "prettier --ignore-path .eslintignore --single-quote --write '**/*.{js,jsx,json,html,css,less,scss,yml}'",
"postlint-styles-fix": "prettier --ignore-path .eslintignore --single-quote --write '**/*.{css,scss}'",
"preinstall": "node ./internals/scripts/CheckYarn.js",
"prestart": "yarn build",
"start": "cross-env NODE_ENV=production electron ./app/main.prod.js",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r #babel/register ./app/main.dev.js",
"start-renderer-dev": "cross-env NODE_ENV=development webpack-dev-server --config configs/webpack.config.renderer.dev.babel.js",
"test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 jest",
"test-all": "yarn lint && yarn flow && yarn build && yarn test && yarn build-e2e && yarn test-e2e",
"test-e2e": "node -r #babel/register ./internals/scripts/CheckBuiltsExist.js && cross-env NODE_ENV=test testcafe electron:./ ./test/e2e/HomePage.e2e.js",
"test-e2e-live": "node -r #babel/register ./internals/scripts/CheckBuiltsExist.js && cross-env NODE_ENV=test testcafe-live electron:./ ./test/e2e/HomePage.e2e.js",
"test-watch": "yarn test --watch"
},
"lint-staged": {
"*.{js,jsx}": [
"cross-env NODE_ENV=development eslint --cache --format=pretty",
"git add"
],
"{*.json,.{babelrc,eslintrc,prettierrc,stylelintrc}}": [
"prettier --ignore-path .eslintignore --parser json --write",
"git add"
],
"*.{css,scss}": [
"stylelint --ignore-path .eslintignore --syntax scss --fix",
"prettier --ignore-path .eslintignore --single-quote --write",
"git add"
],
"*.{html,md,yml}": [
"prettier --ignore-path .eslintignore --single-quote --write",
"git add"
]
},
"main": "./app/main.prod.js",
"build": {
"productName": "ElectronReact",
"appId": "org.develar.ElectronReact",
"files": [
"app/dist/",
"app/app.html",
"app/main.prod.js",
"app/main.prod.js.map",
"package.json"
],
"dmg": {
"contents": [
{
"x": 130,
"y": 220
},
{
"x": 410,
"y": 220,
"type": "link",
"path": "/Applications"
}
]
},
"win": {
"target": [
"nsis",
"msi"
]
},
"linux": {
"target": [
"deb",
"rpm",
"snap",
"AppImage"
],
"category": "Development"
},
"directories": {
"buildResources": "resources",
"output": "release"
},
"publish": {
"provider": "github",
"owner": "electron-react-boilerplate",
"repo": "electron-react-boilerplate",
"private": false
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/electron-react-boilerplate/electron-react-boilerplate.git"
},
"author": {
"name": "Electron React Boilerplate Maintainers",
"email": "electronreactboilerplate#gmail.com",
"url": "https://electron-react-boilerplate.js.org"
},
"contributors": [
{
"name": "Vikram Rangaraj",
"email": "vikr01#icloud.com",
"url": "https://github.com/vikr01"
},
{
"name": "Amila Welihinda",
"email": "amilajack#gmail.com",
"url": "https://github.com/amilajack"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/electron-react-boilerplate/electron-react-boilerplate/issues"
},
"keywords": [
"electron",
"boilerplate",
"react",
"redux",
"flow",
"sass",
"webpack",
"hot",
"reload"
],
"homepage": "https://github.com/electron-react-boilerplate/electron-react-boilerplate#readme",
"jest": {
"testURL": "http://localhost/",
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/internals/mocks/fileMock.js",
"\\.(css|less|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"js",
"jsx",
"json"
],
"transform": {
"^.+\\.jsx?$": "babel-jest"
},
"setupFiles": [
"./internals/scripts/CheckBuiltsExist.js"
]
},
"devDependencies": {
"#babel/core": "^7.4.0",
"#babel/plugin-proposal-class-properties": "^7.4.0",
"#babel/plugin-proposal-decorators": "^7.4.0",
"#babel/plugin-proposal-do-expressions": "^7.2.0",
"#babel/plugin-proposal-export-default-from": "^7.2.0",
"#babel/plugin-proposal-export-namespace-from": "^7.2.0",
"#babel/plugin-proposal-function-bind": "^7.2.0",
"#babel/plugin-proposal-function-sent": "^7.2.0",
"#babel/plugin-proposal-json-strings": "^7.2.0",
"#babel/plugin-proposal-logical-assignment-operators": "^7.2.0",
"#babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0",
"#babel/plugin-proposal-numeric-separator": "^7.2.0",
"#babel/plugin-proposal-optional-chaining": "^7.2.0",
"#babel/plugin-proposal-pipeline-operator": "^7.3.2",
"#babel/plugin-proposal-throw-expressions": "^7.2.0",
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"#babel/plugin-syntax-import-meta": "^7.2.0",
"#babel/plugin-transform-react-constant-elements": "^7.2.0",
"#babel/plugin-transform-react-inline-elements": "^7.2.0",
"#babel/preset-env": "^7.4.2",
"#babel/preset-flow": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"#babel/register": "^7.4.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"chalk": "^2.4.2",
"concurrently": "^4.1.0",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"css-loader": "^3.1.0",
"detect-port": "^1.3.0",
"electron": "^4.1.3",
"electron-builder": "^20.39.0",
"electron-devtools-installer": "^2.2.4",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.11.2",
"enzyme-to-json": "^3.3.5",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-erb": "^0.0.2",
"eslint-config-prettier": "^4.1.0",
"eslint-formatter-pretty": "^2.1.1",
"eslint-import-resolver-webpack": "^0.11.0",
"eslint-plugin-compat": "^3.1.0",
"eslint-plugin-flowtype": "^3.4.2",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-testcafe": "^0.2.1",
"fbjs-scripts": "^1.2.0",
"file-loader": "^3.0.1",
"flow-bin": "^0.95.1",
"flow-runtime": "^0.17.0",
"flow-typed": "^2.5.1",
"husky": "^1.3.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.5.0",
"lint-staged": "^8.1.5",
"mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.11.0",
"opencollective-postinstall": "^2.0.2",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"prettier": "^1.16.4",
"react-test-renderer": "^16.8.6",
"redux-logger": "^3.0.6",
"rimraf": "^2.6.3",
"sass-loader": "^7.1.0",
"sinon": "^7.3.1",
"spectron": "^5.0.0",
"style-loader": "^0.23.1",
"stylelint": "^9.10.1",
"stylelint-config-prettier": "^5.0.0",
"stylelint-config-standard": "^18.2.0",
"terser-webpack-plugin": "^1.2.3",
"testcafe": "^1.1.0",
"testcafe-browser-provider-electron": "^0.0.8",
"testcafe-live": "^0.1.4",
"testcafe-react-selectors": "^3.1.0",
"url-loader": "^1.1.2",
"webpack": "^4.29.6",
"webpack-bundle-analyzer": "^3.1.0",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1",
"webpack-merge": "^4.2.1",
"yarn": "^1.15.2"
},
"dependencies": {
"#fortawesome/fontawesome-free": "^5.8.1",
"#material-ui/core": "^4.2.1",
"#material-ui/icons": "^4.2.1",
"axios": "^0.19.0",
"classnames": "^2.2.6",
"connected-react-router": "^6.3.2",
"core-js": "2",
"devtron": "^1.4.0",
"electron-debug": "^2.1.0",
"electron-log": "^3.0.4",
"electron-store": "^4.0.0",
"electron-updater": "^4.0.6",
"history": "^4.9.0",
"monaco-editor": "^0.19.2",
"monaco-editor-webpack-plugin": "^1.8.2",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "^16.8.6",
"react-hot-loader": "^4.8.2",
"react-panelgroup": "^1.0.7",
"react-redux": "^6.0.1",
"react-resize-observer": "^1.1.1",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-simple-resizer": "^1.3.1",
"react-tabs": "^3.1.0",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "^1.8.5",
"redux": "^4.0.1",
"redux-promise-middleware": "^6.1.1",
"redux-thunk": "^2.3.0",
"shell-quote": "^1.7.2",
"source-map-support": "^0.5.11",
"ssh2": "^0.8.5",
"xterm": "^3.14.5"
},
"devEngines": {
"node": ">=7.x",
"npm": ">=4.x",
"yarn": ">=0.21.3"
},
"collective": {
"url": "https://opencollective.com/electron-react-boilerplate-594"
},
"browserslist": "electron 1.6"
}
I tried with no luck using different versions of monaco-editor and monaco-editor-webpack-plugin as suggested here
This is my webpack config, well the webpack.config of electron-react-boilerplate is kind of messy and maybe there is the error, here is a link of all the config files for webpack used by electron-react-boilerplate I've only changed that file thought.
/**
* Base webpack config used across other specific configs
*/
import path from 'path';
import webpack from 'webpack';
import { dependencies } from '../package.json';
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
export default {
externals: [...Object.keys(dependencies || {})],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: 'ts-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
// entry: {
// // "app": './index.js',
// // Package each language's worker and give these filenames in `getWorkerUrl`
// "editor.worker": 'node_modules/monaco-editor/esm/vs/editor/editor.worker.js',
// "json.worker": 'node_modules/monaco-editor/esm/vs/language/json/json.worker',
// "css.worker": 'node_modules/monaco-editor/esm/vs/language/css/css.worker',
// "html.worker": 'node_modules/monaco-editor/esm/vs/language/html/html.worker',
// "ts.worker": 'node_modules/monaco-editor/esm/vs/language/typescript/ts.worker',
// },
output: {
path: path.join(__dirname, '..', 'app'),
// https://github.com/webpack/webpack/issues/1114
libraryTarget: 'commonjs2'
},
/**
* Determine the array of extensions that should be used to resolve modules.
*/
resolve: {
extensions: ['.js', '.tsx', '.ts', '.jsx', '.json']
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'production'
}),
new MonacoWebpackPlugin(),
new webpack.NamedModulesPlugin()
]
};
For completeness, I'm importing Monaco Editor like so: import * as Monaco from 'monaco-editor' if I use import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; it works but without most of the features that I need.
Add Jest config 'moduleNameMapper':
'monaco-editor':
'<rootDir>/node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts',
Use:
import * as monaco from 'monaco-editor'
Or:
mport { editor, Uri /* , ... */ } from 'monaco-editor'

Categories

Resources