Windows安装node.js

下载了msi安装.默认安装到了progam files目录.

然后试着安装教程:

E:\JinQing\Workspace\node>npm install javascripting
Error: ENOENT, stat 'C:\Documents and Settings\administrator\Application Data\npm'

创建目录npm后就可以安装成功了.
执行时出错:

E:\JinQing\Workspace\node\javascripting>javascripting verify introduction.js
{ [Error: Command failed:
module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\Documents'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3
] killed: false, code: 8, signal: null }

换成全路径执行仍同样:

E:\JinQing\Workspace\node\javascripting>node  "C:\Documents and Settings\administrator\A
pplication Data\npm\node_modules\javascripting\index.js" verify introduction.js
{ [Error: Command failed:
module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\Documents'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3
] killed: false, code: 8, signal: null }

可能是不支持路径中有空格.

重装node.js, 更新安装目录到c:\nodejs.

npm的安装路径前缀(prefix)也需要更改.默认为用户的AppData.


E:\JinQing\Workspace\node\javascripting>npm config ls
; cli configs
registry = "https://registry.npmjs.org/"
user-agent = "npm/1.4.28 node/v0.10.36 win32 ia32"

; builtin config undefined
prefix = "C:\\Documents and Settings\\administrator\\Application Data\\npm"

; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = E:\JinQing\Workspace\node\javascripting
; HOME = C:\Documents and Settings\administrator
; 'npm config ls -l' to show all defaults.


修改npmrc:
prefix=C:\nodejs\node_modules\npm

再将%PATH%环境变量中的npm路径改为:
C:\nodejs\node_modules\npm

E:\JinQing\Workspace\node>npm config ls
; cli configs
registry = "https://registry.npmjs.org/"
user-agent = "npm/1.4.28 node/v0.10.36 win32 ia32"

; builtin config undefined
prefix = "C:\\nodejs\\node_modules\\npm"

; node bin location = C:\nodejs\\node.exe
; cwd = E:\JinQing\Workspace\node
; HOME = C:\Documents and Settings\admin
; 'npm config ls -l' to show all defaults.

运行成功:

E:\JinQing\Workspace\node\javascripting>javascripting verify introduction.js

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@     YOUR SOLUTION IS CORRECT!     @@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


-------------------
# YOU DID IT!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值