How to run a minified Express.js server

170 views Asked by At

I have a minified Express.js project in the 'dist' folder. Grunt uglifies the entire 'dist' folder and places the results in a 'build' folder. Up to this point everything is fine. But, nothing runs afterwards without manually copying the 'package.json' file and then running npm install. All I get is Error: Cannot find module 'dotenv' .

Am I missing something here? Does a minified Express server suppose to run differently? Or are my configurations faulty? The Gruntfile is as follows -

module.exports = function (grunt) {
    const folder = 'some/path';
    grunt.initConfig({

    uglify: {
        files: { 
            src: 'dist/**/*.js',
            dest: folder,
            expand: true,
            flatten: false,
            ext: '.min.js'
        },
    },
});
grunt.loadNpmTasks('grunt-contrib-uglify');

};

Edit: package.json -

{
  "name": "name",
  "version": "1.0.0",
  "description": "Description",
  "main": "src/ser.ts",
  "scripts": {
    "dev": "nodemon",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Someone",
  "license": "",
  "dependencies": {
    "dotenv": "^16.0.1",
    "express": "^4.18.1",
    "nodemailer": "^6.7.5",
    "ts-node": "^10.8.1",
    "typescript": "^4.7.3"
  },
  "devDependencies": {
    "@types/express": "^4.17.13",
    "@typescript-eslint/eslint-plugin": "^5.28.0",
    "@typescript-eslint/parser": "^5.28.0",
    "eslint": "^8.17.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-plugin-import": "^2.26.0",
    "grunt": "^1.5.3",
    "grunt-contrib-uglify": "^5.2.1"
  }
}
0

There are 0 answers