Node.js Heroku NodeJS找不到模块
我有一个在本地运行良好的应用程序,但在部署时无法运行。 信息是Node.js Heroku NodeJS找不到模块,node.js,heroku,module,json-web-token,Node.js,Heroku,Module,Json Web Token,我有一个在本地运行良好的应用程序,但在部署时无法运行。 信息是 Error: Cannot find module 'jsonwebtoken' 即使我在package.json的“dependencies”中有它(不是devdependency) 我尝试了“heroku run bash”,并验证了节点\模块文件夹中存在jsonwebtoken。 最后,我尝试了“heroku本地网站”,效果很好。 但由于某些原因,它在部署时永远不起作用 这是需要jsonwebtoken的文件的开头 var
Error: Cannot find module 'jsonwebtoken'
即使我在package.json的“dependencies”中有它(不是devdependency)
我尝试了“heroku run bash”,并验证了节点\模块文件夹中存在jsonwebtoken。最后,我尝试了“heroku本地网站”,效果很好。 但由于某些原因,它在部署时永远不起作用 这是需要jsonwebtoken的文件的开头
var mongoose = require('mongoose');
var crypto = require('crypto');
console.log('check1');
var jwt = require('jsonwebtoken');
console.log('check2');
它会进入“检查1”而不是“检查2”
这是我的package.json
{
"name": "loc8r",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"engines": {
"node": "~0.10.13",
"npm": "~1.3.2"
},
"dependencies": {
"body-parser": "~1.8.1",
"cookie-parser": "~1.3.3",
"debug": "^2.0.0",
"dotenv": "^4.0.0",
"express": "~4.9.0",
"express-jwt": "^5.3.0",
"jade": "~1.6.0",
"jsonwebtoken": "^8.1.0",
"mongoose": "^4.13.5",
"morgan": "~1.3.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"request": "~2.51.0",
"serve-favicon": "~2.1.3",
"uglify-js": "~2.4.15"
},
"description": "myapp",
"main": "app.js",
"devDependencies": {},
"keywords": [],
"author": "",
"license": "ISC"
}
有人能帮我弄清楚发生了什么吗?从jsonwebtoken的版本来看,您在Heroku上使用的节点版本太旧了。我建议升级到最新版本
我很确定它在本地对您有效,因为您在自己的计算机上运行的是比0.10.X更新的版本。您能粘贴到需要模块和包的文件中吗。谢谢