javascript WebStorm 没有本地存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29097611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 10:05:14  来源:igfitidea点击:

WebStorm There is no locally stored library

javascriptjquerywebstorm

提问by Emre Verim

I'have been working on a project which totally works on jsfiddle.net . However, when i try to run this project in webStorm, i get two errors.

我一直在研究一个完全适用于 jsfiddle.net 的项目。但是,当我尝试在 webStorm 中运行此项目时,出现两个错误。

first : document is not defined

第一的 : 文档未定义

second : no locally stored librarry

第二 : 没有本地存储的库

Before, i post my question here, i searched on stackoverflow but couldn't find any solutions. I already did :

之前,我在这里发布了我的问题,我在 stackoverflow 上进行了搜索,但找不到任何解决方案。我已经做了 :

libraries: libraries that i loaded

图书馆: 我加载的库

and my html codes :

和我的 html 代码:

<!DOCTYPE html>
<html>
<head>
    <title>Super Mario!</title>
    <link rel='stylesheet' type='text/css' href='myMario.css'/>

    <script type='text/javascript' src='//code.jquery.com/jquery-1.11.2.min.js'></script>
</head>
<body>
<img src="http://i1061.photobucket.com/albums/t480/ericqweinstein/mario.jpg"/>
</body>
</html>

why did u get these errors although i loaded libraries and succesfully defined source script in my html ? what should i do ?

尽管我在 html 中加载了库并成功定义了源脚本,但为什么会出现这些错误?我该怎么办 ?

采纳答案by lena

  1. Seems that you get the error when running your .js file directly, via 'Run file_name.js' in it's right-click menu, right? When doing this you are running it using Node.js. But 'document' can't be used in server-side scripts executed by Node.js. It is only defined in client-side javascript, i.e. when running in the browser via a tag in the rendered HTML, not the Javascript API engine running on the server. BTW, your .js file is not even included in your HTML page, as far as I can see from HTML code snippet...

  2. This is not actually an error... WebStorm can't use remote resources available through CDN links for completion. Once it 'sees' such links, it searches for the corresponding library in ~.WebStorm9\system\extLibs\, and, if matching library is not found, prompts you to download it by showing this warning. You can either suppress this warning or agree to download the library: hit Alt+Enter and then either hit the right arrow and choose 'Suppress for tag' or hit Enter to download.

  1. 似乎在直接运行 .js 文件时出现错误,通过右键单击菜单中的“运行 file_name.js”,对吗?执行此操作时,您正在使用 Node.js 运行它。但是 'document' 不能用在 Node.js 执行的服务器端脚本中。它仅在客户端 javascript 中定义,即通过呈现的 HTML 中的标记在浏览器中运行时,而不是在服务器上运行的 Javascript API 引擎。顺便说一句,就我从 HTML 代码片段中看到的而言,您的 .js 文件甚至不包含在您的 HTML 页面中...

  2. 这实际上不是错误... WebStorm 无法使用通过 CDN 链接提供的远程资源来完成。一旦它“看到”这样的链接,它就会在 ~.WebStorm9\system\extLibs\ 中搜索相应的库,如果没有找到匹配的库,它会通过显示此警告提示您下载它。您可以取消此警告或同意下载库:按 Alt+Enter,然后按向右箭头并选择“禁止标记”或按 Enter 下载。

回答by Fryderyk G

You need to select this file link and click Alt + Enter to download this file to your library.

您需要选择此文件链接,然后单击 Alt + Enter 将此文件下载到您的库中。

Screen from WebStorm:

来自 WebStorm 的屏幕:

screen from WebStorm

来自 WebStorm 的屏幕