6

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)
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
    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! 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
    Jun 3, 2020 at 1:29
  • Awesome! Thanks for that information! 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
    Jun 3, 2020 at 1:34

2 Answers 2

9

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!

1
  • Thanks, djfdev. Got the same issue while using audiospritler. Changing 'tmpDir' to 'tmpdir' in node_modules fixed my issue. Feb 20 at 6:40
1

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

2
  • Sorry for the downvote, but this is not an helpful answer. While it works, pinning to a lower than current Node version and not updating the code is bad practice and should not be advised...
    – Antoine
    Dec 7, 2021 at 11:15
  • 2
    s'ok I don't mind. My answer was more to the fact that they said they were a newbie and in a class -- teaching them how to use a version of node that's different than the class is using is not helpful I think. My answer will give them the best version of the node they need to be able to follow the class to the "letter" & sets them up for multiple versions later.
    – Al Joslin
    Apr 15, 2022 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.