Recompiling node dependencies using another node version

前端 未结 6 1643
终归单人心
终归单人心 2021-01-03 02:38

I want to install some dependencies and in this case installing node-pty. But when I run it they give me this error:

Error: The module \'/home/dev/Do

相关标签:
6条回答
  • 2021-01-03 02:59

    In case anyone stumbles over this using WebStorm:

    The terminal window in WebStorm uses system settings for node, but the run configuration could use a different version, so npm install in the terminal could lead to this error. Just change the node version in your run configuration and it should be fine.

    0 讨论(0)
  • 2021-01-03 03:02

    If deleting your node_modules folder and reinstalling doesn't work for you, nor npm rebuild, and you are using nvm, you might have a different problem. Mine was that my npm config prefix was not set to my current nvm node version. So you might try this:

    npm config delete prefix
    npm config set prefix $NVM_DIR/versions/node/vX.X.X
    

    Of course, replace vX.X.X with the nvm installed node version you are using.

    0 讨论(0)
  • 2021-01-03 03:11

    Rebuild the node-pty module using:

    npm rebuild node-pty --update-binary

    0 讨论(0)
  • 2021-01-03 03:19

    The simplest way to be sure is just to delete node_modules and re-run npm i from scratch, that way all modules will definitely be set up for the new Node version.

    0 讨论(0)
  • 2021-01-03 03:19

    If none of the above worked try rebuilding the package manually:

    cd node_modules/<your module>
    node-pre-gyp rebuild
    

    This worked for me

    0 讨论(0)
  • 2021-01-03 03:22

    In my case I was working on a Meteor project for the first time and didn't realize there was difference between meteor npm install and npm install. The former ensures that the correct packages that get installed using using the same npm version that has been tested with your current version of Meteor. My understanding is that this is common with other frameworks such as Electron.

    0 讨论(0)
提交回复
热议问题