Comments (3)
The nodejs warning problem
The nodejs warning problem is caused by the dependent package winston
. This is my dependent tree
░▒▓ ~/node_modules ▓▒░ npm list winston ░▒▓ ✔ base at 18:46:00 ▓▒░
supergui@ /Users/supergui
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]
It can be simply verified by require the package with node.
# Add `--trace-warnings` to trace warning stack
node --trace-warnings
> require("winston")
> (node:77783) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
at emitCircularRequireWarning (node:internal/modules/cjs/loader:887:11)
at Object.get (node:internal/modules/cjs/loader:903:5)
at exports.setLevels (/Users/supergui/node_modules/winston/lib/winston/common.js:35:14)
at Object.<anonymous> (/Users/supergui/node_modules/winston/lib/winston.js:84:8)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
The trace warning are helpful to retrieve the problem is caused by winston.js:84:8
.
This problem is solved with the latest 2.x version of winston
, we can install a [email protected]
then verify it
░▒▓ ~/node_modules ▓▒░ npm install [email protected] ░▒▓ ✔ base at 18:52:16 ▓▒░
added 1 package, removed 25 packages, changed 2 packages, and audited 218 packages in 692ms
Now we can see the winston
is at version 2.4.7
░▒▓ ~/node_modules ▓▒░ npm list ░▒▓ ✔ base at 18:52:30 ▓▒░
supergui@ /Users/supergui
├── [email protected]
└── [email protected]
The warning message is gone now
░▒▓ ~/node_modules ▓▒░ node --trace-warnings ░▒▓ ✔ base at 18:52:32 ▓▒░
Welcome to Node.js v20.11.0.
Type ".help" for more information.
> require("winston")
Fix leetcode-cli
So, we can fix the leetcode
's dependencies manually. We use npm-check-updates to help upgrading package.json
, we must install the tool first.
# Install ncu
npm i -g npm-check-updates
# Update all dependencies to latest minor version
# This will update the `[email protected]` to `[email protected]`
ncu -u
# Install all packages
npm install
# `winston` is indirect dependency.
# Must install the latest 2.x version of winston manually.
npm install [email protected]
from leetcode-cli.
Without the warning message, however, the leetcode-cli
's show ID problem is not fixed still.
░▒▓ ~/node_modules/leetcode-cli ▓▒░ leetcode show 1 ░▒▓ ✔ base at 19:13:06 ▓▒░
[ERROR] Problem not found!
from leetcode-cli.
Got the problem, maybe I will raise a PR to fix this.
keyword = Number(keyword) || keyword;
const problem = problems.find(function(x) {
return x.fid === keyword || x.name === keyword || x.slug === keyword;
});
As shown, the type of x.fid
is actually String
, when querying by ID, unfortunately the keyword is converted to type Number
. This will make x.fid === keyword
be false.
{
state: 'None',
id: 1981,
fid: '1831',
name: 'Maximum Transaction Each Day',
slug: 'maximum-transaction-each-day',
link: 'https://leetcode.cn/problems/maximum-transaction-each-day/description/',
locked: true,
percent: 76.16959064327486,
level: 'Medium',
starred: false,
category: 'database'
}
from leetcode-cli.
Related Issues (20)
- Could not login with both 'leetcode user -l' and 'leetcode user -c' HOT 8
- Stuck on missing plugin install HOT 3
- submit error
- Is providing proxy function on schedule?
- Winston which is dep of prompt will make node 14 fail HOT 1
- Error: Cannot find module 'underscore' HOT 1
- is this repo abandoned? HOT 1
- [ERROR] http error [code=400] HOT 3
- ERROR:leetcode.client.auth:Cannot get cookies from chrome
- [ERROR] failed to load locked problem! HOT 1
- show question by url HOT 2
- **区登录问题 HOT 5
- Can't login! HOT 12
- [ERROR] TypeError: The header content contains invalid characters [0] HOT 1
- `leetcode show 561` returns `[ERROR] failed to load problem!` HOT 1
- template wrong with the problem ID HOT 1
- The first installation on termux can run, after I uninstalled and reinstalled vim as well as installed this plug-in, I couldn't log in later. HOT 1
- Error: getaddrinfo ENOTFOUND leetcode.com HOT 1
- enable scripted submission workflow HOT 2
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 leetcode-cli.