gpt4 book ai didi

javascript - 为什么调用 os.tmpDir() 只会在某些机器上产生错误?

转载 作者:行者123 更新时间:2023-12-04 16:26:53 24 4
gpt4 key购买 nike

我是一名网络开发学生,我的一个 friend 也是。目前,我们正在使用同一课上同一本教科书提供的相同文件。练习的重点是练习 require.js 并探索它可以做什么。我们都采取了相同的步骤来确保下载了正确的包并且 Node 和 npm 版本是最新的。

node index.js在我的机器上运行,服务器开始监听 ::8080并打印 os.tmpDir() is deprecated. Use os.tmpdir() instead.由于我还是新手,我不能 100% 确定弃用实际上是什么,但我知道该应用程序仍然有效。

node index.js在她的机器上运行时,她收到一条错误消息,指出 os.tmpDir()不是函数。我可以去哪里localhost:8080 , 她不能。

我们已经尝试卸载和重新安装 Node (稳定版本和最新版本),比较文件(相同),以及比较包版本。不知何故,尽管我们正在使用的东西(除了我们的机器)之间没有区别,但我们正在经历两种不同的结果。

有什么建议么?

错误信息:

C:\Users\Nereida\Documents\Classes\Summer2020\WEB.215\requirejs\node_modules\mach\lib\utils\makeTemporaryPath.js:4
var TMP_DIR = require("os").tmpDir();
^

TypeError: require(...).tmpDir is not a function
at Object.<anonymous> (C:\Users\Nereida\Documents\Classes\Summer2020\WEB.215\requirejs\node_modules[4mmach[24m\lib\utils\makeTemporaryPath.js:4:29)
at Module._compile (internal/modules/cjs/loader.js:1200:30)[39m
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)[39m
at Module.load (internal/modules/cjs/loader.js:1049:32)[39m
at Function.Module._load (internal/modules/cjs/loader.js:937:14)[39m
at Module.require (internal/modules/cjs/loader.js:1089:19)[39m
at require (internal/modules/cjs/helpers.js:73:18)[39m
at Object.<anonymous> (C:\Users\Nereida\Documents\Classes\Summer2020\WEB.215\requirejs\node_modules[4mmach[24m\lib\utils\saveToDisk.js:6:25)
at Module._compile (internal/modules/cjs/loader.js:1200:30)[39m
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)

最佳答案

答案是 a comment from djfdev :

There's your problem, she needs to use os.tmpdir() with a lowercase d. As you pointed out, there was a deprecation warning about using the version with the uppercase D. It looks like this was removed entirely in node 14.



这么简单……这么多时间。你是我的救星 djfdev!

关于javascript - 为什么调用 os.tmpDir() 只会在某些机器上产生错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62163677/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com