[英]How to run a minified Express.js server
我在“dist”文件夹中有一个缩小的 Express.js 项目。 Grunt 丑化整个 'dist' 文件夹并将结果放在一个 'build' 文件夹中。 到目前为止,一切都很好。 但是,如果不手动复制 'package.json' 文件然后运行npm install
,之后什么都不会运行。 我得到的只是Error: Cannot find module 'dotenv'
。
我在这里错过了什么吗? 缩小的 Express 服务器是否应该以不同的方式运行? 还是我的配置有问题? Gruntfile 如下 -
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');
};
编辑: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"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.