Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我不知道';我不知道为什么我的npm没有var uc=require(';大写';)的响应;_Javascript_Npm - Fatal编程技术网

Javascript 我不知道';我不知道为什么我的npm没有var uc=require(';大写';)的响应;

Javascript 我不知道';我不知道为什么我的npm没有var uc=require(';大写';)的响应;,javascript,npm,Javascript,Npm,我只是在关注w3school npm教程,但没有回应 我正在使用MacBookPro 2019,并使用Vs代码对其进行编程 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta htt

我只是在关注w3school npm教程,但没有回应

我正在使用MacBookPro 2019,并使用Vs代码对其进行编程

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <p id=uc></p>
        <script>
            var uc = require('upper-case');
            document.getElementById('uc').innerHTML = uc("asdjkad");
        </script>
</body>
</html>

我希望html/javascript可以运行大写的节点

require
不是javascript或浏览器环境的内置部分。它是Node.js(非浏览器)环境的内置部分,是由各种库和绑定器(如Webpack和Browserify)提供的功能

如果要在浏览器托管的代码中使用
npm
模块,必须:

  • 通过
    script
    标记将其包括在内,前提是它不依赖任何其他模块(不太可能),或者

  • 使用能够理解
    要求
    语法的绑定器,并能将模块代码绑定到与浏览器兼容的脚本中

  • (base) xxx:~ yyy$ npm ls -g
    /Users/yyy/.npm-global/lib
    ├─┬ increase-memory-limit@1.0.7
    │ └─┬ glob@7.1.4
    │   ├── fs.realpath@1.0.0
    │   ├─┬ inflight@1.0.6
    │   │ ├── once@1.4.0 deduped
    │   │ └── wrappy@1.0.2
    │   ├── inherits@2.0.4
    │   ├─┬ minimatch@3.0.4
    │   │ └─┬ brace-expansion@1.1.11
    │   │   ├── balanced-match@1.0.0
    │   │   └── concat-map@0.0.1
    │   ├─┬ once@1.4.0
    │   │ └── wrappy@1.0.2 deduped
    │   └── path-is-absolute@1.0.1
    ├── jquery@3.4.1
    └── upper-case@1.1.3