最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why does calling os.tmpDir() produce an error on only some machines? - Stack Overflow

programmeradmin6浏览0评论

I am a web development student and a friend of mine is as well. Currently we are utilizing the same files provided by the same textbook in the same class. The point of the exercise is to practice with require.js and explore what it can do. Both of us have taken the same steps to ensure that the proper packages are downloaded and that node and npm versions are up to date.

When node index.js is run on my machine, the server begins listening on ::8080 and prints os.tmpDir() is deprecated. Use os.tmpdir() instead. As I am still fairly new, I'm not 100% sure what deprecation actually is, but I know that the app still works.

When node index.js is run on her machine, she receives an error stating os.tmpDir() is not a function. Where I can go to localhost:8080, she cannot.

We have tried uninstalling and reinstalling node (both stable and latest versions), comparing files (which are identical), and comparing package versions. Somehow, it seems that despite there being no differences between what we are working with (aside from our machines), we are experiencing two different results.

Any suggestions?

The error message:

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)

I am a web development student and a friend of mine is as well. Currently we are utilizing the same files provided by the same textbook in the same class. The point of the exercise is to practice with require.js and explore what it can do. Both of us have taken the same steps to ensure that the proper packages are downloaded and that node and npm versions are up to date.

When node index.js is run on my machine, the server begins listening on ::8080 and prints os.tmpDir() is deprecated. Use os.tmpdir() instead. As I am still fairly new, I'm not 100% sure what deprecation actually is, but I know that the app still works.

When node index.js is run on her machine, she receives an error stating os.tmpDir() is not a function. Where I can go to localhost:8080, she cannot.

We have tried uninstalling and reinstalling node (both stable and latest versions), comparing files (which are identical), and comparing package versions. Somehow, it seems that despite there being no differences between what we are working with (aside from our machines), we are experiencing two different results.

Any suggestions?

The error message:

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)
Share Improve this question edited Jun 3, 2020 at 2:51 MultiplyByZer0 7,1193 gold badges34 silver badges48 bronze badges asked Jun 3, 2020 at 1:09 TillyPiddleTillyPiddle 2111 gold badge2 silver badges6 bronze badges 10
  • It would be better if you could show a bit more of the code causing the problem. But off the cuff, I would say you have two different version of node.js. – ced-b Commented Jun 3, 2020 at 1:25
  • Currently, we do not have the same version of node.js, but previously we have and the results are the same. I have done my best to take complete control over the installation process and version checking to ensure at least that was correct. Appreciate the expedient feedback though! – TillyPiddle Commented Jun 3, 2020 at 1:28
  • 1 Deprecation means that the use of something is discouraged, for a variety of possible reasons. Usually it implies that something is no longer being supported by the maintainers of the library, and might be removed entirely in a future version. – djfdev Commented Jun 3, 2020 at 1:29
  • Awesome! Thanks for that information! – TillyPiddle Commented Jun 3, 2020 at 1:30
  • 1 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 Commented Jun 3, 2020 at 1:34
 |  Show 5 more comments

2 Answers 2

Reset to default 12

The answer comes as 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.

So simple... so much time. You are my savior djfdev!

you can fix this problem if you use node > 12

pin your project to use node <= 12 with nvm

echo 'lts/erbium' > .nvmrc nvm use

ref: https://github.com/nvm-sh/nvm/blob/master/README.md

发布评论

评论列表(0)

  1. 暂无评论