我有一个正在将Express用于后端API的项目。该项目正在我的本地计算机上运行,但是当我尝试在Linux VM上部署该项目时,出现错误“找不到模块'Express'”。
我产生此错误的步骤是克隆并提示到存储库中,然后运行npm install
。 express在package.json文件中作为依赖项列出。我尝试显式运行npm install express
和npm install -g express
,都说他们添加和/或更新了程序包,但未返回任何错误。我还查看了node_modules文件夹,那里也有一个express文件夹。
我的package.json:
{
"name": "user-backend",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev-start": "nodemon server.js",
"nvm-start": "nvm use 8.11.3",
"postnvm-start": "nodemon server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"cors": "^2.8.4",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"faker": "^4.1.0",
"helmet": "^3.12.1",
"jsonwebtoken": "^8.3.0",
"mongoose": "^5.2.2",
"morgan": "^1.9.0",
"request": "^2.88.0",
"slugify": "^1.3.1",
"validator": "^10.4.0"
},
"devDependencies": {
"nodemon": "^1.18.1"
}
}
任何帮助将不胜感激。谢谢
答案 0 :(得分:2)
这最终是我导入中的一个简单语法错误(“ Express”和“ express”)