首页 \ 问答 \ 更新Node.js后无法使用npm install(Can't use npm install after update Node.js)

更新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
更新时间:2022-05-27 19:05

最满意答案

删除不起作用的原因是因为您将点击处理程序附加到$('.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");
});

相关问答

更多
  • 试试这个: $(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 ...
  • 它不起作用,因为在元素绑定到特定元素/类组合后动态添加/删除类。 也就是说,在与该类有任何链接之前,您将点击事件添加到具有“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函数返回对象本身,因此您可以链接以下方法: element.css('attribute', 'value').html('value').append('element').click(function() {}); 但是当绑定一个事件处理程序时,它就是.click() ,它必须将逻辑存储在事件发生时调用的回调中。 链接实际如何工作的一个例子: var testObject = { methodA : function() { // some logic ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)