WebStorm 在 Node.js 应用程序中错误地显示未解析的方法
WebStorm incorrectly shows unresolved method in Node.js app
我已经安装了 WebStorm 2019.3 并且 bcryptjs
库有一个奇怪的未解决函数警告。该项目是 Node.js,我做了 npm install
。
还有其他依赖项可以正常工作,但这个特别不行。有什么想法吗?
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');
const MongoClient = require('mongodb').MongoClient;
MongoClient.connect(uri) // OK, not highlighted
const token = jwt.sign({ // OK, not highlighted
if (bcrypt.compareSync(password, user.password)) { // KO, highlighted as unresolved
请尝试取消排除 node_modules\bcryptjs\dist
文件夹:右键单击它,选择 标记目录 As/Not 排除;重新打开项目。
我还建议安装 bcryptjs
打字以获得更好的编码帮助:将光标放在 require('bcryptjs')
中的 'bcryptjs'
上,点击 Alt+Enter
,选择 安装 Typescript 定义以获得更好的类型信息。
参见 https://www.jetbrains.com/help/webstorm/2019.3/configuring-javascript-libraries.html#ws_jsconfigure_libraries_ts_definition_files
我已经安装了 WebStorm 2019.3 并且 bcryptjs
库有一个奇怪的未解决函数警告。该项目是 Node.js,我做了 npm install
。
还有其他依赖项可以正常工作,但这个特别不行。有什么想法吗?
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');
const MongoClient = require('mongodb').MongoClient;
MongoClient.connect(uri) // OK, not highlighted
const token = jwt.sign({ // OK, not highlighted
if (bcrypt.compareSync(password, user.password)) { // KO, highlighted as unresolved
请尝试取消排除 node_modules\bcryptjs\dist
文件夹:右键单击它,选择 标记目录 As/Not 排除;重新打开项目。
我还建议安装 bcryptjs
打字以获得更好的编码帮助:将光标放在 require('bcryptjs')
中的 'bcryptjs'
上,点击 Alt+Enter
,选择 安装 Typescript 定义以获得更好的类型信息。
参见 https://www.jetbrains.com/help/webstorm/2019.3/configuring-javascript-libraries.html#ws_jsconfigure_libraries_ts_definition_files