我正在使用 nodejs 访问Parse。它在本地运行良好。但是当我将代码推送到 Heroku 时,出现如下错误:
6T13:34:58+00:00 app[worker.1]:
2013-03-16T13:34:58+00:00 app[worker.1]: module.js:340
2013-03-16T13:34:58+00:00 app[worker.1]: throw err;
2013-03-16T13:34:58+00:00 app[worker.1]: at Function.Module._resolveFilename (module.js:338:15)
2013-03-16T13:34:58+00:00 app[worker.1]: at Function.Module._load (module.js:280:25)
2013-03-16T13:34:58+00:00 app[worker.1]: at Module.require (module.js:364:17)
2013-03-16T13:34:58+00:00 app[worker.1]: at Object.Module._extensions..js (module.js:474:10)
2013-03-16T13:34:58+00:00 app[worker.1]: **Error: Cannot find module 'Parse'**
2013-03-16T13:34:58+00:00 app[worker.1]: ^
2013-03-16T13:34:58+00:00 app[worker.1]: at require (module.js:380:17)
2013-03-16T13:34:58+00:00 app[worker.1]: at Object.<anonymous> (/app/server.js:2:10)
2013-03-16T13:34:58+00:00 app[worker.1]: at Module._compile (module.js:456:26)
2013-03-16T13:34:58+00:00 app[worker.1]: at Module.load (module.js:356:32)
2013-03-16T13:34:58+00:00 app[worker.1]: at Function.Module.runMain (module.js:497:10)
2013-03-16T13:34:58+00:00 app[worker.1]: at Function.Module._load (module.js:312:12)
2013-03-16T13:34:59+00:00 heroku[worker.1]: Process exited with status 8
2013-03-16T13:34:59+00:00 heroku[worker.1]: State changed from up to crashed
但是我可以使用 heroku 模拟器的“foreman start”来运行我的代码。
正如@PeterLyons 要求的那样。Profile文件如下:
worker: node server.js
包.json
{
"name": "app name",
"description": "app description",
"version": "1.0.0",
"private": true,
"dependencies": {
"cron": ">=1.0.1",
"jsdom" : ">=0.5.2",
"parse" : "*"
}
}
当我将代码推送到 heroku 时,我可以看到它正确地为我获取了解析依赖项。
parse@1.2.2 /tmp/build_3jl0a1qf6bwt3/node_modules/parse
localStorage@1.0.2 /tmp/build_3jl0a1qf6bwt3/node_modules/parse/node_modules/localStorage
xmlhttprequest@1.5.0 /tmp/build_3jl0a1qf6bwt3/node_modules/parse/node_modules/xmlhttprequest
Dependencies installed
-----> Building runtime environment
-----> Discovering process types
Procfile declares types -> worker
我不知道为什么运行时会出错。
谢谢