更新Node.js后无法使用npm install(Can't use npm install after update Node.js)
我将Node.js更新为5.x,之后我无法使用npm install。 每次使用它都会导致错误:
$ npm install react-motion npm ERR! Darwin 15.3.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "am2" npm ERR! node v5.0.0 npm ERR! npm v3.3.6 npm ERR! code EINVALIDTYPE npm ERR! typeerror Error: Argument #1: Expected string but got object npm ERR! typeerror at markDeps (/usr/local/lib/node_modules/npm/lib/install/deps.js:87:5) npm ERR! typeerror at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35 npm ERR! typeerror at Array.forEach (native) npm ERR! typeerror at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11 npm ERR! typeerror at Array.forEach (native) npm ERR! typeerror at asyncMap (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8) npm ERR! typeerror at Array.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8) npm ERR! typeerror at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14) npm ERR! typeerror at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5) npm ERR! typeerror at recalculateMetadata (/usr/local/lib/node_modules/npm/lib/install/deps.js:112:3) npm ERR! typeerror This is an error with npm itself. Please report this error at: npm ERR! typeerror <http://github.com/npm/npm/issues> npm ERR! Please include the following file with any support request: npm ERR!
和npm安装不再工作,我不能回到以前版本的节点!
$ sudo -i # npm install -g n // causes same errors! # n 4.4.2; // not working anymore.
我应该完全重新安装node.js吗? 或者我可以解决它吗? 任何建议都会非常感激。
I updated Node.js to 5.x, and after then I can't use npm install. Every time to use this, it causes errors:
$ npm install react-motion npm ERR! Darwin 15.3.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "am2" npm ERR! node v5.0.0 npm ERR! npm v3.3.6 npm ERR! code EINVALIDTYPE npm ERR! typeerror Error: Argument #1: Expected string but got object npm ERR! typeerror at markDeps (/usr/local/lib/node_modules/npm/lib/install/deps.js:87:5) npm ERR! typeerror at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35 npm ERR! typeerror at Array.forEach (native) npm ERR! typeerror at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11 npm ERR! typeerror at Array.forEach (native) npm ERR! typeerror at asyncMap (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8) npm ERR! typeerror at Array.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8) npm ERR! typeerror at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14) npm ERR! typeerror at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5) npm ERR! typeerror at recalculateMetadata (/usr/local/lib/node_modules/npm/lib/install/deps.js:112:3) npm ERR! typeerror This is an error with npm itself. Please report this error at: npm ERR! typeerror <http://github.com/npm/npm/issues> npm ERR! Please include the following file with any support request: npm ERR!
and npm install not working anymore, I can't go back to previous version of node!
$ sudo -i # npm install -g n // causes same errors! # n 4.4.2; // not working anymore.
Should I reinstall node.js entirely? Or can I fix it? Any advice will very appreciate.
原文:https://stackoverflow.com/questions/38029133
最满意答案
删除不起作用的原因是因为您将点击处理程序附加到
$('.remove')
但删除按钮尚不存在。 单击$('.btn-primary)
对象后,将创建删除按钮。使用移除按钮作为选择器,将单击处理程序附加到包含食物项行的表(假设它已存在)。
$('table').on('click', '.remove', function() { console.log("works"); });
The reason remove isn't working is because your are attaching the click handler to
$('.remove')
but the remove buttons do not yet exist. Your remove buttons are being created after your$('.btn-primary)
object is clicked.Attach the click handler to the table (assuming it already exists) that will contain your food item rows, using your remove buttons as a selector.
$('table').on('click', '.remove', function() { console.log("works"); });
相关问答
更多-
jQuery点击输入和功能?(jQuery Click input and Function?)[2024-04-12]
试试这个: $(document).ready(function() { jQuery('#special').click(function () { specialFunction(); return false; }); }); 但我建议你使用实时指令,以便应用于以后可能出现的任何链接,这样做: $(document).ready(function() { $('#special').live("click", function() { ... -
这是由于Javascript的事件传播机制,你可以阅读更多: http://www.quirksmode.org/js/events_order.html Javascript:触发多个鼠标事件 您可以通过禁用内部div处的单击事件来避免这种情况,如下所示: $('.postcard').click( function(evt) { evt.stopPropagation(); } ); This is due to the event propagation mechanism of Javascrip ...
-
JQuery和点击功能(JQuery and the click function)[2023-01-29]
它不起作用,因为在元素绑定到特定元素/类组合后动态添加/删除类。 也就是说,在与该类有任何链接之前,您将点击事件添加到具有“show-para”类的链接(或者可能反过来,具体取决于您的默认值) 在任何一种情况下,jQuery都有live功能来解决这个问题,只需将click处理程序更改为.live('click', function(){ }) It doesn't work because you are dynamically adding/removing the class after the ele ... -
这不是与slidetoggle相关的问题。 它不是针对随机导航菜单项,它只是不确定你想要哪一个。 你使用一个类作为选择器,这就是原因。 这条线: $('.sub-menu').slideToggle(); 我认为是导致你的问题。 当使用类作为选择器时,与选择器匹配的任何其他元素也将受到影响。 不仅是你试图改变的那个。 你可以为所有这些ID分配不同的ID并动态地将id值传递给你的click函数,但这不是必需的,因为对$(this)的简单调用将解决你的问题。 没有看到你的HTML,这很难给出一个解决方案,但如 ...
-
您的代码无法正常工作,因为在将位置更改为新页面后,您的脚本将被重新加载,并且click事件的上下文丢失。 如果您希望(新)页面在每次访问时滚动,则可以简单地将第二个函数设置为它的onload事件。 如果您只希望它通过特定链接访问时向下滚动,则可以向链接的href的url添加参数,并通过在该新页面上获取该参数,确定是否已通过该链接访问链接并相应地滚动。 jQuery('.link').click(function(e) { e.preventDefault(); location = 'htt ...
-
删除不起作用的原因是因为您将点击处理程序附加到$('.remove')但删除按钮尚不存在。 单击$('.btn-primary)对象后,将创建删除按钮。 使用移除按钮作为选择器,将单击处理程序附加到包含食物项行的表(假设它已存在)。 $('table').on('click', '.remove', function() { console.log("works"); }); The reason remove isn't working is because your are attaching ...
-
那这个呢: $(function(){ $('.nyroModal').nyroModal(); shortcut.add("Ctrl+Q",function() { $('a.nyroModal').click(); }); }); What about this: $(function(){ $('.nyroModal').nyroModal(); shortcut.add("Ctrl+Q",function() { ...
-
这听起来像你想要click功能使用可从代码中的其他地方调用的命名函数。 如果是这样,只需在jQuery就绪函数之外定义函数,并在click方法中按名称使用它们。 function id1Click() { ... } ... $(function() { $('#id1').click(id1Click); }); It sounds like you want to have the click functions use a named function which is callable ...
-
在您的代码中 , click事件在.vouch被附加到.vouch元素,但随后被“卡住”到该元素。 即使您更改了类,事件处理程序仍然绑定到li元素本身。 要做你想做的事,请使用事件委托 。 这会将 click事件委托给document ,但会在执行代码之前检查单击元素是否具有单击时的vouch类。 $(document).ready(function () { $(document).on('click', '.vouch', function () { alert("000" ...
-
Jquery点击没有功能(Jquery click without function)[2022-07-03]
jQuery函数返回对象本身,因此您可以链接以下方法: element.css('attribute', 'value').html('value').append('element').click(function() {}); 但是当绑定一个事件处理程序时,它就是.click() ,它必须将逻辑存储在事件发生时调用的回调中。 链接实际如何工作的一个例子: var testObject = { methodA : function() { // some logic ...