Search code examples
javascriptnode.jswindowsnpmreferenceerror

npm ReferenceError: primordials is not defined (node.js)


I know this question is posted many times but I tried the solutions and I can not resolve it. I am trying to work wit npm however I get this error:

     evalmachine.<anonymous>:35
    } = primordials;
        ^
    
    ReferenceError: primordials is not defined
        at evalmachine.<anonymous>:35:5
        at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:8)
        at Module._compile (internal/modules/cjs/loader.js:1138:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
        at Module.load (internal/modules/cjs/loader.js:986:32)
        at Function.Module._load (internal/modules/cjs/loader.js:879:14)
        at Module.require (internal/modules/cjs/loader.js:1026:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at Object.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:3:27)
        at Module._compile (internal/modules/cjs/loader.js:1138:30)

I can not even execute npm -v to see the version. I tried to downgrade node to version 10. I tried to uninstall-reinstall node so many times (From remove application settings). I tried to create a file called "npm-shrinkwrap.json" insde the npm folder where package.json exists. But there is no use.

And I can't see an "AppData" folder in the "Users/User" path but I can access it by "cd" from the command line. I don't understand how it is not visible.

Thank you.


Solution

  • It is resolved!

    I know I said I uninstalled npm, but just uninstalling it from the settings were not enough. I tried to uninstall it deleting the node releted directories on my computer following this post: https://stackoverflow.com/a/11178106/13806114. And then I installed node again and it worked!

    Thank you.