安装node.js可能出现的问题及解决方法

我在安装node.js时遇到很多问题,在网上搜索了很久,才找到这些靠谱的解决办法,现在收集整理一下,以备日后使用。


1.运行node.js出现 “socket: (10107)系统调用失败



原因: 

    winsock出错

解决方法:

    以管理员身份打开cmd,使用以下命令 netsh winsock reset

重启电脑即可。


以管理员分身打开cmd

C:\Windows\System32路径下找到cmd

右击cmd,点击以管理员的身份运行,可以看到一个以管理员身份运的cmd程序。


参考网站:http://loli.la/2016/09/28/e8-bf-90-e8-a1-8c-node-js-e5-87-ba-e7-8e-b0-socket-10107-e7-b3-bb-e7-bb-9f-e8-b0-83-e7-94-a8-e5-a4-b1-e8-b4-a5-e3-80-82-e9-94-99-e8-af-af/

 

http://jingyan.baidu.com/article/e73e26c0f87c2424adb6a7f1.html


2.执行grunt -v

Reading "???" Gruntfile...ERROR

A valid Gruntfile could not be found. Please see the getting started guide for

more information on how to configure grunt: http://gruntjs.com/getting-started

Fatal error: Unable to find Gruntfile.


注意:grunt命令时安装grunt-cli模块时产生的,如果只是安装grunt模块是不会有grunt命令的。

 

Gruntfile配置文件,在当前目录下新建一个文件,命名为Gruntfile.js,内容如下。

//包装函数

module.exports = function(grunt) {

    //任务配置

    grunt.initConfig({

        'hello-world':{}

    });

    //自定义任务

    grunt.registerTask('hello-world', 'My "asyncfoo" task.', function() {

        grunt.log.writeln('hello world');

    });

    grunt.registerTask('default', ['hello-world']);

};

然后再当前目录执行下grunt命令,输出如下:

C:\模拟磁盘\projects\grunt\grunt-helloworld>grunt

Running "hello-world" task

hello world

 

Done, without errors.

 

这里自定义一个输出hello world的模块,然后让grunt框架使用它。

 

参考网站:http://blog.csdn.net/larrywangsun/article/details/27428093



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值