npx command not found

前端 未结 8 844
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 21:57

I am working with webpack and I need to execute ./node_modules/webpack/bin/webpack.js using npx. npx webpack would run the webpack bin

相关标签:
8条回答
  • 2020-12-02 22:14

    Remove NodeJs and npm in your system and reinstall it by following commands

    Uninlstallation

    sudo apt remove nodejs
    sudo apt remove npm

    Fresh Installation

    sudo apt install nodejs
    sudo apt install npm

    Configuration optional, in some cases users may face permission errors.

    1. user defined directory where npm will install packages

      mkdir ~/.npm-global

    2. configure npm

      npm config set prefix '~/.npm-global'

    3. add directory to path

      echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile

    4. refresh path for the current session

      source ~/.profile

    5. cross-check npm and node modules installed successfully in our system

      node -v
      npm -v

    Installation of npx

    sudo npm i -g npx
    npx -v

    Well-done we are ready to go... now you can easily use npx anywhere in your system.

    0 讨论(0)
  • 2020-12-02 22:21

    Updating node helped me, whether that be from the command line or just re-downloading it from the web

    0 讨论(0)
  • 2020-12-02 22:27

    if you are using Linux system, use sudo command

    sudo npm i -g npx
    
    0 讨论(0)
  • 2020-12-02 22:29

    try :

    sudo su
    

    then

    npm i npx 
    or 
    npi i -g npx
    

    check your npx version by

    npx -v
    
    0 讨论(0)
  • 2020-12-02 22:31

    npx should come with npm 5.2+, and you have node 5.6 .. I found that when I install node using nvm for Windows, it doesn't download npx. so just install npx globally:

    npm i -g npx
    

    In Linux or Mac OS, if you found any permission related errors use sudo before it.

    sudo npm i -g npx
    
    0 讨论(0)
  • 2020-12-02 22:34

    I returned to a system after a while, and even though it had Node 12.x, there was no npx or even npm available. I had installed Node via nvm, so I removed it, reinstalled it and then installed the latest Node LTS. This got me both npm and npx.

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