检查您当前是否在浏览器中(而不是在节点中)安装npm i in-browser用法var in_browser = require ( 'in-browser' ) ; if ( in_browser ) { // code for clients only } else { // code for servers only }