金庆的专栏

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  423 随笔 :: 0 文章 :: 454 评论 :: 0 Trackbacks

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!
posted on 2015-01-31 13:32 金庆 阅读(1003) 评论(0)  编辑 收藏 引用 所属分类: 9. 其它2. 网游开发

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理