Tengo un proyecto en typescript que contine un backend en node + typescript que funciona con la injeccion de dependencias.
Tengo la libreria jsonwebtoken para gestionar los tokens. he instaldo tanto jsonwebtokens como @types/jsonwebtokens
En dev(windows) funciona todo perfecto pero cuando corro el docker-compose y levanta el proyecto en produccion (ubuntu) salta este error:
src/Contexts/Shared/domain/value-object/Jwt.ts(3,17): error TS2307: Cannot find module 'jsonwebtoken' or its corresponding type declarations.
Os dejo el dockerfile:
FROM node:12.16.3-slim
WORKDIR /code
COPY package.json package-lock.json ./
RUN npm install
Os dejo el docker-composer:
version: '3.8'
services:
application_backend-platform:
build: .
command: bash -c "npm run build && npm run start:application_backend-platform"
ports:
- 4300:4300
environment:
- MONGO_URL=
volumes:
- .:/code:delegated
- node_modules:/code/node_modules:delegated
volumes:
node_modules:
Aqui esta el packaje-json para que veias que esta instalada la dependencia:
{
"name": "typescript-node",
"version": "1.0.0",
"description": "",
"repository": {
"url": ""
},
"license": "",
"engines": {
"node": ">=10.15.0",
"npm": ">=6.7.0"
},
"scripts": {
"dev:application_backend-platform": "SET NODE_ENV=dev && ts-node-dev --ignore-watch node_modules --inspect=0.0.0.0:9267 src/apps/Application_backend-platform/server.ts",
"test": "npm run test:unit && npm run test:features",
"test:unit": "SET NODE_ENV=test && jest",
"test:features": "SET NODE_ENV=test && cucumber-js -p default",
"start:saas_backend": "NODE_ENV=production node dist/src/apps/Saas_backend/server",
"start:application_backend-platform": "NODE_ENV=production node dist/src/apps/Application_backend-platform/server",
"start:backOffice_backend": "NODE_ENV=production node dist/src/apps/BackOffice_backend/server",
"build": "npm run build:clean && npm run build:tsc && npm run build:di",
"build:tsc": "tsc -p tsconfig.prod.json",
"build:di": "copy 'src/**/*.{json,yaml}' dist/src",
"build:clean": "rm -r dist; exit 0"
},
"dependencies": {
"@types/bson": "^4.0.2",
"@types/compression": "^1.7.0",
"@types/convict": "^5.2.1",
"@types/errorhandler": "1.5.0",
"@types/express": "^4.17.6",
"@types/glob": "^7.1.1",
"@types/helmet": "0.0.47",
"@types/jsonwebtoken": "^8.5.0",
"@types/mongodb": "^3.5.18",
"@types/node": "^14.0.3",
"@types/uuid": "^8.0.0",
"@types/uuid-validate": "0.0.1",
"body-parser": "^1.19.0",
"bson": "^4.0.4",
"compression": "^1.7.4",
"convict": "^6.0.0",
"copy": "^0.3.2",
"errorhandler": "^1.5.1",
"express": "^4.17.1",
"express-promise-router": "^4.0.1",
"glob": "^7.1.6",
"helmet": "^3.22.0",
"http-status": "^1.4.2",
"jsonwebtoken": "^8.5.1",
"mandrill-api": "^1.0.45",
"mongodb": "^3.5.7",
"node-dependency-injection": "^2.6.3",
"ts-node": "^8.10.1",
"typescript": "^3.9.2",
"uuid": "^8.0.0",
"uuid-validate": "0.0.3",
"winston": "^3.2.1"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.51",
"@types/cucumber": "^6.0.1",
"@types/faker": "^4.1.12",
"@types/jest": "^25.2.3",
"@types/supertest": "^2.0.9",
"cucumber": "^6.0.5",
"faker": "^4.1.0",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "10.2.4",
"prettier": "^2.0.5",
"supertest": "^4.0.2",
"ts-jest": "^26.0.0",
"ts-node-dev": "^1.0.0-pre.44",
"tslint": "^6.1.2",
"tslint-config-prettier": "~1.18.0",
"tslint-eslint-rules": "^5.4.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"{src,tests}/**/*.ts": [
"prettier --write",
"tslint --fix",
"git add"
]
}
}
** Nota los imports en los archivos de typescript en el backend de node los estoy haciendo de la siguiente manera:
import jwt from 'jsonwebtoken';