在VM共享目录中安装npm模块并发出咕unt声 [英] Installing npm modules in a VM shared directory and grunt issues

查看:76
本文介绍了在VM共享目录中安装npm模块并发出咕unt声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个开发环境,而npm却给我带来了问题.这是我的情况:

我有一台运行Windows和VMWare Player的开发机.我有一个配置有Apache,PHP,NodeJS等的Ubuntu Server VM(无UI).由于该VM没有UI,因此我想使用主机OS进行开发.我设置了一个共享目录,该目录在VM中可以通过/mnt/hgfs/source/<项目名称>访问.

当我尝试在此目录中运行 npm install 时,问题就来了.我看到很多错误,例如 Error:UNKNOWN,symlink'../requirejs/bin/r.js'.我知道我的package.json文件是可以的,因为如果我将所有文件复制出共享并复制到常规的unix目录(/var/www/<项目名称>)中,则 npm install 可以正常工作.因此npm在共享目录中安装模块时遇到问题.

我认为我可以通过在全球范围内安装节点软件包来解决此问题,但是无论出于何种原因,GruntJS爱好者解决方案

尝试以下操作:

  npm install --no-bin-links 

Grunt应该是本地的,因为插件和 gruntfile.js 可能需要特定版本的Grunt才能运行任务.如果其他开发人员想要运行您的任务,则只需发出 npm install 并设置它们即可.(有关详细信息,请参见.)> grunt-cli 是全局的,用于运行 grunt

的本地版本

I'm trying to put together a development environment and npm is causing me problems. Here is my scenario:

I have a development machine running Windows and VMWare Player. I have a Ubuntu Server VM (no UI) which is configured with Apache, PHP, NodeJS etc. As the VM has no UI I want to use the host OS for development. I set up a shared directory which in the VM is accessed as /mnt/hgfs/source/<project name>.

The problem comes when I attempt to run npm install within this directory. I see a lot of errors like Error: UNKNOWN, symlink '../requirejs/bin/r.js'. I know that my package.json file is OK because if I copy all files out of the share and into a regular unix directory (/var/www/<project name>) npm install works fine. So npm has a problem installing modules in the shared directory.

I thought I could get around this by installing the node packages globally but, for whatever reason, the GruntJS enthusiasts don't like that and it must be present locally. I then tried to create an npm link from global to local but that just results in a new error: Error: May not delete: /usr/lib/node_modules/grunt. I have full permissions on the /usr/lib/node_modules directory and all sub-directories.

I really don't want to write the entire project using a command-line text editor in the VM but it looks like I cannot have my code-base in a directory available to both the host and guest OS through VMWare.

I would very much appreciate any suggestions on how to either 1) allow npm modules to be installed in my shared directory, 2) run Grunt globally, or 3) solve the npm link error I'm seeing.

EDIT: Shortly after posting this I realised the fundamental issue here - it's not possible to create symbolic links within a VM shared directory when the host OS is Windows. As npm install uses symlinks by default it didn't work, and this is why the accepted solution does work.

解决方案

Try the following:

npm install --no-bin-links

Grunt should be local since the plugins and gruntfile.js may require a certain version of Grunt in order to run your tasks. If another developer would like to run your tasks, they could just issue an npm install and they are set. (See this for more info.) grunt-cli is global which is used to run the local version of grunt

这篇关于在VM共享目录中安装npm模块并发出咕unt声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆