简体   繁体   English

未将Node.js模块安装在正确的位置

[英]nodejs modules not installed in the proper place

I am using nodjs 0.10.12 in Windows server 2012. I succesfully installed node using msi installer. 我在Windows Server 2012中使用nodjs 0.10.12。我使用msi安装程序成功安装了节点。 I tried to install pg , websockets , url , and policyfile , using npm install (name of module) . 我尝试使用npm install (name of module)安装pgwebsocketsurlpolicyfile

But, modules got installed in C\\Users\\Administrator\\AppData\\Roaming\\npm-cache , I guessed they will be installed in C\\Program Files (x86)\\nodejs\\node_modules , just like in another project I did. 但是,模块已安装在C\\Users\\Administrator\\AppData\\Roaming\\npm-cache ,我猜它们将安装在C\\Program Files (x86)\\nodejs\\node_modules ,就像在另一个项目中一样。

Anyway I was getting the error 无论如何,我遇到了错误

module.js:340
throw err;
      ^
Error: Cannot find module 'websocket'

I used this C\\Program Files (x86)\\nodejs\\node_modules npm install websocket --force as described here . 我用这个C\\Program Files (x86)\\nodejs\\node_modules npm install websocket --force描述这里 Worked for websocket, but now, I was getting the error for pg. 为websocket工作,但现在,我遇到了pg的错误。 Used the --force for pg and got the error for the url. 对pg使用--force并得到url错误。 Fixed it with --force , got the error for policyfile, also fixed it with --force . 使用--force进行了修复,获取了policyfile的错误,同时使用--force修复。

Now I get no errors and my website works fine. 现在我没有任何错误,我的网站运行正常。

But : 但是:

1-Files of those modules are still in C\\Users\\Administrator\\AppData\\Roaming\\npm-cache . 这些模块的1个文件仍位于C\\Users\\Administrator\\AppData\\Roaming\\npm-cache

2-In the console, when I start the server , I get warning native modules not compiled. xor performance will be degraded 2-在控制台中,当我启动服务器时,收到warning native modules not compiled. xor performance will be degraded warning native modules not compiled. xor performance will be degraded and warning native modules not compiled. utf-8 validation disabled warning native modules not compiled. xor performance will be degradedwarning native modules not compiled. utf-8 validation disabled warning native modules not compiled. utf-8 validation disabled . warning native modules not compiled. utf-8 validation disabled

Is this wrong? 错了吗 Will they affect my system/project? 它们会影响我的系统/项目吗? Did I messed up big time? 我搞砸了大时间吗? Should I delete the extra folders? 我应该删除多余的文件夹吗? Please advice 请指教

Thanks in advance 提前致谢

I had this issue too. 我也有这个问题。 Turns out I simply mistyped the name of the install. 原来我只是输入了错误的安装名称。 When you install the websocket from the Node.js comand prompt, make sure you spell it correctly, ie npm install websocket (not websockets with an 's'). 从Node.js comand提示符下安装websocket时,请确保正确拼写,即npm install websocket (而不是带有's'的websockets)。 You can check your previous spelling by looking in the node_modules folder where ever you initially installed the module on, presumably on the root drive for your user. 您可以通过在最初将模块安装到的node_modules文件夹(可能是用户的根驱动器)中查看,来检查以前的拼写。 ( C:/Users/<mynamehere>/node_modules/ ) C:/Users/<mynamehere>/node_modules/

If this was the case, don't bother trying to simply change the name of the folder name to websocket , it didn't work for me. 如果是这种情况,请不要试图简单地将文件夹名称更改为websocket ,这对我没有用。 Delete the folder and reinstall the module websocket through the node.js command prompt. 删除文件夹,然后通过node.js命令提示符重新安装模块websocket。 I hope this helps, there are other solutions floating around in regards to globally specified installs and correct folder directory for where these installs were made, either of these could also be your solution, depending. 希望对您有所帮助,关于全局指定的安装以及进行这些安装的正确文件夹目录,还有其他解决方案,这取决于您的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM