Comments (8)
@atian25 no problem :) I happened to be up and about on GitHub 👍
from nodejs-depd.
Hi @atian25 can you provide some more details? I see you're in @eggjs and so I assume you are trying to add this module to that module? Typically when you see a non-useful stack, it's because the following note was missed in the README:
[...] this module uses the calling file to get the boundary for the call stacks, so you should always create a new deprecate object in each file and not within some central file.
I can take a look to see what is happening if you have code I can try, though.
from nodejs-depd.
thanks, we use it at https://github.com/eggjs/egg-core/blob/master/lib/egg.js#L156
I'll read the doc again, thanks~
from nodejs-depd.
Gotcha. Yea, you cannot use this module in that way in order for the stack traces to make sense. You should always create a new deprecate object in each file you are deprecating items, because that is how the file boundary is determined. If you create it in a single, central file, then the module will latch to that file as the stack boundary and then you'll end up with useless stack traces.
from nodejs-depd.
The usage in https://github.com/eggjs/egg-core/blob/1dda9fa9d1d61a1d06913202294ac8690dbef90d/lib/loader/file_loader.js is how the module needs to be loaded: you require('depd')(namespace)
at the top of the file and only ever invoke the deprecate
function within that same file.
It is not clear to me where you're using the deprecate property in that file you linked to, but the essence is that you cannot centralize the creation of this module like you're doing there.
from nodejs-depd.
egg has plugin system, so we define a getter of app.deprecate
then plugins and apps can use like this.app.deprecate()
https://github.com/eggjs/egg/blob/984d7320881adf9420e5c7e49d62d5530ad887dd/lib/egg.js#L319
from nodejs-depd.
Hi @atian25 thanks. So it's not possible to use this module in that way, as per the readme instructions. For the file https://github.com/eggjs/egg/blob/984d7320881adf9420e5c7e49d62d5530ad887dd/lib/egg.js you need to
- Add
const deprecate = require('depd')('egg')
at the top - Change the line you referenced to
deprecate('please use app.config.env instead')
from nodejs-depd.
got, thanks for reply timely.
from nodejs-depd.
Related Issues (20)
- Drop eval usage HOT 21
- Cannot redefine property: callSiteToString HOT 2
- Call-site calculation does not fail gracefully when Stack information is unavailable HOT 14
- Call site calculation fails when importing an esm'ed package that imports sequelize internally HOT 14
- Respect --no-deprecation and process.noDeprecation HOT 17
- TypeError: eval is not a function HOT 8
- Why is this library overwriting Error type? HOT 5
- Turkish Language Problem HOT 2
- Incopatibile with --enable-source-maps node 12 option HOT 7
- (!) Use of eval is strongly discouraged, rollup HOT 1
- compatibility with Node.js' source-map implementation HOT 12
- please rewrite nodejs-depd with modern syntax HOT 1
- Compatibility with --disallow-code-generation-from-strings HOT 9
- Use of eval() is strongly discouraged, as it poses security risks HOT 9
- Calling `process.cwd()` from index.js can be problematic HOT 4
- callSite.getFileName() is not Function HOT 5
- `callSite.getFileName` is not a function HOT 10
- NodeJS 20.11.0 fails when building snapshot.
- compatibility with node --frozen-intrinsics security option HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-depd.