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)
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'm working on a nextJS project which uses mikro-orm , and I'm facing this error for days now:
C:\Users\BossTrails\Documents\core.nest-main_2\node_modules\.bin\mikro-orm:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
I get the error above when I try to run the comman - npm run migration:fresh:seed
Here is my package.json
{
"name": "backend",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:server": "nest start --config nest-cli.server.json",
"migration:fresh": "node node_modules/.bin/mikro-orm migration:fresh",
"migration:fresh:seed": "node node_modules/.bin/mikro-orm migration:fresh --seed",
"migration:init": "node node_modules/.bin/mikro-orm migration:create --initial",
"migration:create": "node node_modules/.bin/mikro-orm migration:create",
"migration:up": "node node_modules/.bin/mikro-orm migration:up",
"migration:down": "node node_modules/.bin/mikro-orm migration:down",
"migration:down:zero": "node node_modules/.bin/mikro-orm migration:down --to 0",
"migration:rollout": "node node_modules/.bin/ts-node ./src/scripts/rollout-migrations",
"start:server:dev": "nest start --config nest-cli.server.json --watch",
"start:server:debug": "nest start --config nest-cli.server.json --debug --watch",
"start:server:dist": "node dist/server",
"start:worker": "nest start --config nest-cli.worker.json",
"start:worker:dev": "nest start --config nest-cli.worker.json --watch",
"start:worker:debug": "nest start --config nest-cli.worker.json --debug --watch",
"start:worker:dist": "node dist/worker",
"lint": "./node_modules/.bin/eslint \"{src,test}/**/*.ts\"",
"lint:fix": "./node_modules/.bin/eslint \"{src,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": {
"#faker-js/faker": "^6.1.1",
"#mikro-orm/cli": "^5.1.1",
"#mikro-orm/core": "^5.1.1",
"#mikro-orm/knex": "^5.0.0-dev.434",
"#mikro-orm/migrations": "^5.1.1",
"#mikro-orm/nestjs": "^5.0.1",
"#mikro-orm/postgresql": "^5.1.1",
"#mikro-orm/reflection": "^5.1.1",
"#mikro-orm/seeder": "^5.1.1",
"#nestjs/axios": "^0.0.3",
"#nestjs/common": "^8.0.0",
"#nestjs/config": "^1.0.2",
"#nestjs/core": "^8.0.0",
"#nestjs/event-emitter": "^1.1.1",
"#nestjs/graphql": "^9.1.2",
"#nestjs/jwt": "^8.0.0",
"#nestjs/passport": "^8.0.1",
"#nestjs/platform-express": "^8.0.0",
"#nestjs/platform-socket.io": "^8.4.4",
"#nestjs/platform-ws": "^8.4.4",
"#nestjs/schedule": "^1.0.2",
"#nestjs/swagger": "^5.1.4",
"#nestjs/websockets": "^8.4.4",
"#svtslv/nestjs-ioredis": "^1.0.2",
"#types/cookie": "^0.5.1",
"#types/socket.io": "^3.0.2",
"amqp-ts": "^1.8.0",
"apollo-server-core": "^3.6.7",
"apollo-server-express": "^3.5.0",
"aws-sdk": "^2.1034.0",
"axios": "^0.24.0",
"bcrypt": "^5.0.1",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
"cookie": "^0.5.0",
"file-type": "^16.5.3",
"firebase-admin": "^10.0.0",
"graphql": "^15.8.0",
"graphql-subscriptions": "^2.0.0",
"graphql-ws": "^5.5.5",
"ioredis": "^4.28.0",
"nestjs-redis": "^1.3.3",
"otp-generator": "^3.0.0",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"swagger-ui-express": "^4.1.6",
"txtgen": "^2.2.8",
"typedi": "^0.10.0"
},
"devDependencies": {
"#nestjs/cli": "^8.0.0",
"#nestjs/schematics": "^8.0.0",
"#nestjs/testing": "^8.0.0",
"#types/bcrypt": "^5.0.0",
"#types/cron": "^1.7.3",
"#types/express": "^4.17.13",
"#types/faker": "^5.5.9",
"#types/imagemin": "^8.0.0",
"#types/imagemin-jpegtran": "^5.0.1",
"#types/ioredis": "^4.27.8",
"#types/jest": "^27.0.1",
"#types/lodash": "^4.14.176",
"#types/multer": "^1.4.7",
"#types/node": "^16.0.0",
"#types/passport-jwt": "^3.0.6",
"#types/passport-local": "^1.0.34",
"#types/supertest": "^2.0.11",
"#types/uuid": "^8.3.1",
"#typescript-eslint/eslint-plugin": "^5.16.0",
"#typescript-eslint/parser": "^5.16.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.1.3",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.0.6",
"prettier": "^2.6.0",
"prettier-eslint": "^13.0.0",
"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.6.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"mikro-orm": {
"useTsNode": true,
"configPaths": [
"./src/mikro-orm.config.ts",
"./dist/mikro-orm.config.js"
]
},
"files": [
"src"
]
}
I've cleaned node packages
I've reinstalled npm and yarn
The same error I am getting with npm and yarn
I'm using:
windows 10
node version: 16.15.0
npm: 8.5.5
I fixed it!
The problem was a windows issue. Windows had issues reading a bash file or something. But the whole set up works well on Linux or Mac.
So you can either switch to mac or linux.
OR
Use WSL ( the windows Linux distro). Install node and npm on the WSL , connect VS code to the WSL so that you can run and edit the code on VS code.
Run you scripts with the linux bash terminal which will now be set up in vs code
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 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"
}
}
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.