Npm 安装phantomjs/any包全局特定版本

Npm 安装phantomjs/any包全局特定版本,npm,phantomjs,npm-install,Npm,Phantomjs,Npm Install,我想全局安装phantomjs版本1.9.8 当我运行phantomjs版本时,它显示了2.1.1 所以我运行了npm卸载phantomjs-g,结果成功了 接下来,当我尝试运行npm安装phantomjs-g 1.9.8时,它抛出了以下错误 > npm WARN deprecated phantomjs@2.1.7: Package renamed to > phantomjs-prebuilt. Please update 'phantomjs' package referenc

我想全局安装phantomjs版本1.9.8

当我运行phantomjs版本时,它显示了2.1.1

所以我运行了
npm卸载phantomjs-g
,结果成功了

接下来,当我尝试运行
npm安装phantomjs-g 1.9.8
时,它抛出了以下错误

> npm WARN deprecated phantomjs@2.1.7: Package renamed to
> phantomjs-prebuilt. Please update 'phantomjs' package references to
> 'phantomjs-prebuilt' npm ERR! Darwin 14.5.0 npm ERR! argv
> "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "phantomjs"
> "1.9.20" npm ERR! node v4.4.7 npm ERR! npm  v2.15.8 npm ERR! code E404
> 
> npm ERR! 404 Registry returned 404 for GET on
> https://registry.npmjs.org/1.9.20 npm ERR! 404  npm ERR! 404 '1.9.20'
> is not in the npm registry. npm ERR! 404 You should bug the author to
> publish it (or use the name yourself!) npm ERR! 404  npm ERR! 404 Note
> that you can also install from a npm ERR! 404 tarball, folder, http
> url, or git url.
> 
> npm ERR! Please include the following file with any support request:
> npm ERR!     /work/development/test-folder/npm-debug.log
如何在全球范围内安装所需版本的pantomjs


PS:我不使用自制,希望避免使用自制

在阅读npm api文档后,我找到了解决方案

npm安装-gphantomjs@version

总的来说

npm安装-gpackageName@version

如果您没有权限,请使用
sudo
access

这甚至可以在全球范围内降低程序包的级别