For this project, I have a monorepo with 2 workspaces (api and frontEnd). I have upgraded node from V10 to V16 recently and the migration is almost complete. I can run it locally, but building is not possible anymore.
When I run yarn workspace api start:dev
, defined in api/package.json as "start:dev": "cross-env NODE_ENV=development npx ts-node-dev -r dotenv/config -r tsconfig-paths/register --respawn --transpile-only src/index.ts"
, it runs smoothly on localhost.
When I run yarn workspace api build:ts
, defined in api/package.json as yarn run tsc
, I get errors of the following type (I kept only 1 error per file to respect the question character limit, but there are over 2000 lines):
../node_modules/@types/babel__traverse/index.d.ts(68,50): error TS1005: ']' expected.
../node_modules/@types/express-serve-static-core/index.d.ts(99,68): error TS1110: Type expected.
../node_modules/@types/node/assert.d.ts(12,72): error TS1144: '{' or ';' expected.
../node_modules/@types/node/index.d.ts(72,1): error TS1084: Invalid 'reference' directive syntax.
../node_modules/@types/sinon/index.d.ts(30,54): error TS1005: ',' expected.
../node_modules/express-validator/src/chain/validators-impl.d.ts(79,27): error TS1005: ',' expected.
../node_modules/express-validator/src/chain/validators.d.ts(66,27): error TS1005: ',' expected.
../node_modules/express-validator/src/validation-result.d.ts(13,64): error TS1005: ',' expected.
This is my api/tsconfig.json:
{
"compilerOptions": {
"lib": ["es6"],
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./build",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"skipLibCheck": true,
"baseUrl": "./src",
"paths": {
"@/*": ["./*"]
}
},
"include": ["src/**/*"],
"exclude": [
"**/node_modules/*",
"node_modules",
"**/*.test.ts",
"**/test/**/*"
]
}
This is my api/package.json:
{
"name": "api",
"version": "3.8.18",
"description": "",
"license": "NONE",
"private": true,
"nohoist": [
"**/express*",
"**/express*/**"
],
"engines": {},
"scripts": {
"build:ts": "yarn run tsc",
"start": "yarn run start:prod",
"start:prod": "cross-env NODE_ENV=production node -r ./tsconfig-paths-bootstrap.js build/index.js",
"start:dev": "cross-env NODE_ENV=development npx ts-node-dev -r dotenv/config -r tsconfig-paths/register --respawn --transpile-only src/index.ts",
"test": "cross-env NODE_ENV=test mocha 'test/**/*.test.ts' --timeout 60000 --recursive --no-deprecation -r ts-node/register -r tsconfig-paths/register --file test/testUtils/test-setup.ts ",
"test:unit": "yarn run test --grep @unit",
"test:integration": "yarn run test --grep @int",
"typeorm:cli": "ts-node -r tsconfig-paths/register ../node_modules/typeorm/cli -f ./src/ormconfig.ts",
"migration:generate": "yarn run typeorm:cli migration:generate -n",
"migration:create": "yarn run typeorm:cli migration:create -n",
"migration:run": "yarn run typeorm:cli migration:run",
"migration:revert": "yarn run typeorm:cli migration:revert",
"migration:show": "yarn run typeorm:cli migration:show"
},
"devDependencies": {
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.4",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/mocha": "^9.1.0",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.15",
"@types/node-fetch": "^3.0.2",
"@types/sinon": "^10.0.10",
"@types/sinon-chai": "^3.2.8",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"dotenv": "^16.0.0",
"mocha": "^9.2.0",
"sinon": "^13.0.1",
"sinon-chai": "^3.7.0",
"sinon-express-mock": "^2.2.1",
"supertest": "^6.2.2",
"ts-node": "10.4.0",
"ts-node-dev": "^1.1.8",
"tsconfig-paths": "^3.12.0",
"typescript": "^4.5.5"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"async-exit-hook": "^2.0.1",
"aws-sdk": "^2.1069.0",
"axios": "^0.25.0",
"babel-plugin-module-resolver": "^4.1.0",
"body-parser": "^1.19.1",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"eslint-import-resolver-node": "^0.3.2",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "6.x",
"eslint-plugin-react": "7.x",
"express": "^4.17.2",
"express-jwt": "^6.1.0",
"express-jwt-authz": "^2.4.1",
"express-query-boolean": "^2.0.0",
"express-validator": "^6.14.0",
"jwks-rsa": "^2.0.5",
"morgan": "^1.10.0",
"morgan-json": "^1.1.0",
"node-fetch": "^3.2.0",
"pg": "^8.7.3",
"prettier": "^2.5.1",
"redis": "^4.0.3",
"sinon": "^13.0.1",
"slugify": "^1.6.5",
"tsconfig-paths": "^3.12.0",
"tspath": "^1.3.7",
"typeorm": "^0.2.41",
"winston": "^3.5.1",
"winston-daily-rotate-file": "^4.6.0"
}
}
yarn install
(No effect)"types": []
to "compilerOptions" in api/tsconfig.json (Babel and sinon errors have dissapeared, but I still get ~150 lines of the following ones)../node_modules/@types/express-serve-static-core/index.d.ts(99,68): error TS1110: Type expected.
../node_modules/@types/node/assert.d.ts(12,72): error TS1144: '{' or ';' expected.
../node_modules/@types/node/index.d.ts(72,1): error TS1084: Invalid 'reference' directive syntax.
../node_modules/express-validator/src/chain/validators-impl.d.ts(79,27): error TS1005: ',' expected.
nvm v
1.1.8.
nvm current
v16.13.2
yarn -v
1.22.18
yarn run tsc --version
Version 2.9.2
Thank you for your help!
I have found the culprit. It was the "tspath" dependency.
To remove it, I did "yarn workspace api remove tspath".