I build my application locally into a
dist
folder; package.json is also copied overnpm install --production
is run in the dist folderdist
folder is then zipped upZip is uploaded to server, where it is unzipped
Attempting to run the application on the server results in
Error: cannot find module <module_name>
This error occurs for any module unless I manually run npm install <module_name>
after the unzip
Everything works fine if I run it from my dist
folder, so it's not an issue with the pre-zip part
Running npm install --production
after the unzip doesn't resolve anything (just says that all modules are up-to-date)
Deleting node_modules
on the server, then running npm install --production
makes everything work fine
Unzipping the zip file locally then running the application works fine
What am I missing/doing wrong?
EDIT: package.json:
{
"name": "app-name",
"version": "0.0.1",
"scripts": {
"start": "index.js"
},
"dependencies": {
"body-parser": "^1.18.2",
"email-validator": "^1.1.1",
"express": "^4.16.2",
"express-jwt": "^5.3.0",
"express-jwt-permissions": "^1.0.0",
"firebase-admin": "^5.5.1",
"jsonwebtoken": "^8.1.0",
"mailgun-js": "^0.13.1",
"mysql2": "^1.5.0",
"password-hash-and-salt": "^0.1.4",
"randomstring": "^1.1.5",
"reflect-metadata": "^0.1.10",
"sequelize": "^4.22.6",
"sequelize-typescript": "^0.5.0"
},
"devDependencies": {
"@types/express": "^4.0.39",
"@types/express-jwt": "0.0.38",
"@types/jsonwebtoken": "^7.2.4",
"@types/node": "^8.0.51",
"@types/sequelize": "^4.0.79",
"babel-core": "^6.26.0",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-babel": "^7.0.0",
"gulp-ssh": "^0.6.0",
"gulp-typescript": "^3.2.3",
"gulp-zip": "^4.0.0",
"merge-stream": "^1.0.1",
"typescript": "^2.6.1"
}
}