NodeJS 错误:挂接(`userconfig`)加载失败

pu82cl6c  于 2023-06-22  发布在  Node.js
关注(0)|答案(2)|浏览(163)

npm安装后,得到错误一样,我已经检查了每个配置文件,也安装了lodash手动后,但仍然不工作

error: A hook (`userconfig`) failed to load!
error: Error: In Sails v1.x, `sails.config.globals._` must be either `false` or an object (typically the value of `require('lodash')`)
    at Sails.exposeGlobals (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\exposeGlobals.js:47:44)
    at Sails.wrapper [as exposeGlobals] (D:\Node_Project\POS\trunk\node_modules\@sailshq\lodash\lib\index.js:3250:19)
    at emitNone (events.js:91:20)
    at Sails.emit (events.js:185:7)
    at Sails.emitter.emit (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\after.js:50:11)
    at D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\loadHooks.js:111:15
    at Hook.initialize (D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:154:14)
    at Hook.wrapper [as initialize] (D:\Node_Project\POS\trunk\node_modules\@sailshq\lodash\lib\index.js:3250:19)
    at D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:88:16
    at D:\Node_Project\POS\trunk\node_modules\sails\node_modules\async\dist\async.js:486:20
wmomyfyw

wmomyfyw1#

第一步:确保您已经使用npm install安装了依赖项第二步:检查此应用程序是否为兼容版本的Sails构建。

1u4esq0p

1u4esq0p2#

config/globals.js中尝试以下代码

module.exports.globals = {
  moment: true,
  models: false,
  sails: true,
  async: require('async'),
  _: require('lodash'),
};

相关问题