【发布时间】:2015-04-06 21:10:46
【问题描述】:
我正在构建一个 Sails 应用程序,但它突然停止工作。我运行sudo node app.js 启动应用程序并在终端上抛出错误:
A hook (`userconfig`) failed to load!
error: Error: Invalid module: [object Object],(...)
我尝试重新安装所有模块,但没有成功。 我已经阅读了一些问题,例如here 和here,但这不是我想要的。我会在这里提供我的 package.json 文件,以防有人需要阅读:
{
"name": "myapp",
"private": true,
"version": "0.0.1",
"description": "my app description",
"keywords": [],
"dependencies": {
"bcrypt": "~0.7.6",
"ejs": "~0.8.4",
"grunt": "0.4.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-jst": "~0.6.0",
"grunt-contrib-less": "0.11.1",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-sails-linker": "~0.9.5",
"grunt-sync": "~0.0.4",
"include-all": "~0.1.3",
"mqtt": "^1.0.8",
"node-uuid": "^1.4.2",
"passport": "^0.2.1",
"passport-local": "^1.0.0",
"rc": "~0.5.0",
"sails": "~0.10.5",
"sails-disk": "~0.10.0",
"sails-mysql": "^0.10.11"
},
"scripts": {
"start": "node app.js",
"debug": "node debug app.js"
},
"main": "app.js",
"repository": {
"type": "git",
"url": "my repo"
},
"author": "Me",
"license": ""
}
任何帮助都会很棒...我提供了我认为必要的信息,但如果需要我会提供更多信息。
编辑: 我在更多问题here 上看到过,但也没有用。
【问题讨论】:
-
只是一个建议:不要使用 sudo 运行 node.js 应用程序。如果你想使用 80 端口,最好使用代理(比如 nginx 或其他)
-
嗨@GlenSwift。我使用 sudo 运行,因为我的应用程序使用端口 443(我使用带有自签名证书的 https 进行测试)。但我会听从你的建议。谢谢!
-
关于您的问题:听起来您的某个配置文件中有语法错误,或者在 .sailsrc 中修改了配置的路径。请检查一下。
-
@GlenSwift 我没有更改任何配置文件。但我会检查并回答我的反馈。
-
@GlenSwift 谢谢!我已经解决了我的问题。这是我在配置文件夹中添加的名为“countries.json”的配置文件。我删除了那个文件,我的应用程序工作了!可能与 Sails.js 的另一个配置冲突。但这是一种奇怪的行为,因为我之前在 config 文件夹中运行过带有该文件的应用程序,并且工作起来就像一个魅力。请发布答案,我会将其标记为解决方案!