Chrome Development Tool: [VM] file from javascript

本文解释了Chrome浏览器中VM(scriptId)的概念及其在JavaScript引擎V8中的作用,并介绍了当遇到未知脚本文件名时如何利用sourceURL进行调试的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[VM] (scriptId) has no special meaning. It's a dummy name to help us to distinguish code which are not directly tied to a file name, such as code created using eval and friends. In the past, all of these scripts were just labelled (program). If you're interested, just look up "[VM]"in the source code of Chromium, you will discover that these numbers have no significant meaning outside the developer tools.

[VM] (scriptId)没有特殊含义。它是一个虚拟名称,帮助我们区分那些没有直接绑定到文件名的代码,例如使用eval和friends创建的代码。在过去,所有这些脚本都被称为(程序)。如果你感兴趣,只要在Chromium的源代码中查找“[VM]”,你会发现这些数字在开发工具之外没有什么重要的意义。

[VM] (scriptId) was renamed to VMscriptId a while ago, and here is the direct link to search result in case the value changes again.

It is abbreviation of the phrase Virtual Machine. In the Chrome JavaScript engine (called V8) each script has its own script ID.

Sometimes V8 has no information about the file name of a script, for example in the case of an eval. So devtools uses the text "VM" concatenated with the script ID as a title for these scripts.

Some sites may fetch many pieces of JavaScript code via XHR and eval it. If a developer wants to see the actual script name for these scripts she can use sourceURL. DevTools parses and uses it for titles, mapping etc.

[VM] (scriptId)前段时间已重命名为VMscriptId,为防止再次更改值,此处为直接搜索结果链接。

它是短语Virtual Machine的缩写。在Chrome JavaScript引擎(称为V8)中,每个脚本都有自己的脚本ID。

有时候V8没有关于脚本文件名的信息,例如eval。因此devtools使用文本“VM”与脚本ID连接作为这些脚本的标题。

一些网站可能会通过XHR获取很多JavaScript代码并对其进行计算。如果开发人员希望看到这些脚本的实际脚本名称,她可以使用sourceURL。DevTools会将其解析并用于标题、映射等。
 

chrome下调试本地js,不能设置断点,在控制台显示VM+数字+要调试的文件名。

解决方案:

1》、在调试<source>的左下方有一个{}图标,提示“pretty print”,点击,chrome就会另外打开一个:formatted的文件,在里面就可以调试了。

原因估计是chrome将源文件误认为是压缩过的,所以不能断点调试,重新格式化下就行了。

2》、清空缓存或重启浏览器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值