npm install : specify package.json?

后端 未结 2 1459
星月不相逢
星月不相逢 2021-02-20 13:05

How can I tell npm to use another package.json when running \"npm install\" ?

All I need is npm install -f packages-win32.json Or is there a trick or anoth

2条回答
  •  萌比男神i
    2021-02-20 13:47

    The npm command doesn't allow specifying a specific package.json file but here's work-around to install specific or all package.json files:

    Create npm-install.sh file with the source below and run with this command:

    source npm-install.sh

    or:

    bash npm-install.sh

    #!/bin/bash
    set +ex;
    
    cp -f package.json temp;
    echo "Installing all package-*.json...";
    
    for File in *.json; do
      echo -e "\nFile: $File";
      mv -f $File package.json;
      npm install;
    done
    
    cp -f temp package.json;
    rm -f temp;
    #EOF
    

提交回复
热议问题