admin管理员组文章数量:1287488
I am looking at this specific line of code to understand what it is or to find some documentation about it.
.js
const Lucid = use('Lucid')
I am trying to write a test in adonisjs using mocha and it gives me the following error "ReferenceError: use is not defined"
I am looking at this specific line of code to understand what it is or to find some documentation about it.
https://github./adonisjs/adonis-rally/blob/c7378d2c3984bffba1049f50e771318ea447107c/app/Model/Channel.js
const Lucid = use('Lucid')
I am trying to write a test in adonisjs using mocha and it gives me the following error "ReferenceError: use is not defined"
-
This is not a standard part of Javascript or node.js. In that particular code, it looks like something similar to
require()
that would be in some library which you do not appear to have available. – jfriend00 Commented Dec 21, 2016 at 17:23 -
6
There is no
use
keyword. That is a function call - some library defines it. You don't seem to have that library loaded. – VLAZ Commented Dec 21, 2016 at 17:23 - Look in the package.json to see the installed packages – Andrew Li Commented Dec 21, 2016 at 17:24
- I copied the package json from that project i linked to my project and I still cannot run a test. My model looks exactly the same as the model linked. – shed_fortest Commented Dec 21, 2016 at 17:36
2 Answers
Reset to default 7The use()
function is provided by adonis.js
.
use(namespace/alias)
Fetch a binding using it’s namespace or alias.
The adonis-lucid package has an example of how to create a model that looks identical to the code that you've linked in your question. Creating a model docs
To plete the answer. use()
function is provided by the IoC Container of AdonisJs (adonis-fold).
This function will try to resolve a binding or a namespace defined in your Adonis configuration file and will then fallback to the default require()
function to import a package if it didn't find anything.
本文标签: nodejswhat is the 39use39 keyword in javascriptStack Overflow
版权声明:本文标题:node.js - what is the 'use' keyword in javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741313294a2371771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论