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"
}
}
Related
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.
I am testing the sample code of javascript.
There is script like simple.js under demos directory.
I run demo by this command yarn build-demos && http-server demos/
simple.js is compiled to simple_bundle.js and server works.
However everytime I change simple.js, I need to restart server.
Is there any good short cut for this purpose??
I am not familiar with npm and webpack
Any help is appreciated.
My package.json is here below:
{
"name": "#magenta/sketch",
"version": "0.2.0",
"description": "Make sketches in the browser with machine learning.",
"main": "es5/index.js",
"types": "es5/index.d.ts",
"jsdelivr": "dist/magentasketch.js",
"unpkg": "dist/magentasketch.js",
"dependencies": {
"#tensorflow/tfjs": "^1.0.2"
},
"devDependencies": {
"#types/clone": "^0.1.30",
"#types/file-saver": "^1.3.0",
"#types/ndarray": "^1.0.6",
"#types/node": "^12.0.1",
"#types/tape": "^4.2.32",
"browserify": "^16.5.1",
"clang-format": "^1.2.3",
"clone": "^1.0.4",
"file-saver": "^1.3.8",
"file-saver-typescript": "^1.0.1",
"fs": "0.0.1-security",
"http-server": "^0.12.1",
"in-publish": "^2.0.0",
"minimist": "^1.2.5",
"path": "^0.12.7",
"tape": "^4.9.0",
"ts-loader": "^5.3.0",
"ts-node": "^5.0.1",
"tsify": "^3.0.4",
"tslint": "^5.9.1",
"typedoc": "^0.16.9",
"typedoc-plugin-sourcefile-url": "^1.0.3",
"typescript": "^3.3.3333",
"webpack": "^4.24.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
},
"scripts": {
"prepublish": "yarn lint && yarn build && yarn bundle",
"build": "tsc",
"bundle": "webpack --config ./webpack/lib.config.ts",
"lint": "tslint -c ../tslint.json -p . -t verbose",
"test": "ts-node node_modules/tape/bin/tape src/**/*_test.ts",
"build-demos": "webpack --config ./webpack/demo.config.ts",
"run-demos": "yarn build-demos && http-server demos/",
"serve-demos": "http-server demos/",
"serve-dist": "http-server dist/",
"docs": "sh ../scripts/generate-docs.sh 'sketch'"
},
"author": "Magenta",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/tensorflow/magenta-js.git"
}
}
You might need to use Nodemon.
You install nodemon by npm i nodemon
In package.json you add a script: "dev": "nodemon dist/index.js"
Execute the code in the console by adding npm run dev
It should work as you want
You may consider using Nodemon.
After a while without playing with Nuxtjs today I decided to start a project on it with PWA support, everything installed and the template created almost as usual, just missing a relatively useless directory - assets -, but when I go to `yarn dev` several of these errors appear:
ERROR ENOENT: no such file or directory, open '/home/runner/anisite/node_modules/.cache/pwa/icon/iphonexsmax_1242x2688.png'
then at the end it appears:
Killed
error Command failed with exit code 137
My package.json
{
"name": "anisite",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "yarn lint:js",
"test": "jest"
},
"dependencies": {
"#nuxtjs/axios": "^5.13.6",
"#nuxtjs/pwa": "^3.3.5",
"core-js": "^3.15.1",
"nuxt": "^2.15.7"
},
"devDependencies": {
"#babel/eslint-parser": "^7.14.7",
"#nuxtjs/eslint-config": "^6.0.1",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/tailwindcss": "^4.2.0",
"#vue/test-utils": "^1.2.1",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^27.0.5",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-nuxt": "^2.0.0",
"eslint-plugin-vue": "^7.12.1",
"jest": "^27.0.5",
"postcss": "^8.3.5",
"prettier": "^2.3.2",
"vue-jest": "^3.0.4"
}
}
Edits:
I already deleted the cache directories
I already reinstalled everything
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.
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)