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\npmE:\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!