How to resolve such issue 'no such environment: default' when 'npm install' dependencies

I met such issue 'no such environment: default'  when npm install some libs, such as iconv, hashlib...

The workround is to modify /usr/local/lib/node/wafadmin/Build.py like below:

def get_env(self):
        return self.env_of_name(DEFAULT)

The original is like

def get_env(self):
        return self.env_of_name('default')

The issue is like below:

> node-expat@1.4.0 install /usr/local/lib/node_modules/xml2js-expat/node_modules/node-expat
> node-waf configure build

Checking for program g++ or c++          : /usr/bin/g++
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok 
Checking for node path                   : not found
Checking for node prefix                 : ok /usr/local
Checking for header expat.h              : no such environment: default
Traceback (most recent call last):
  File "/usr/local/bin/node-waf", line 16, in <module>
    Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
    prepare_impl(t, cwd, ver, wafdir)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
    main()
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
    fun(ctx)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 241, in configure
    conf.sub_config([''])
  File "/usr/local/bin/../lib/node/wafadmin/Configure.py", line 221, in sub_config
    self.recurse(k, name='configure')
  File "/usr/local/bin/../lib/node/wafadmin/Utils.py", line 634, in recurse
    f(self)
  File "/usr/local/lib/node_modules/xml2js-expat/node_modules/node-expat/wscript", line 13, in configure
    errmsg = "not installed")
  File "/usr/local/bin/../lib/node/wafadmin/Tools/config_c.py", line 444, in check
    ret = self.run_c_code(*k, **kw)
  File "/usr/local/bin/../lib/node/wafadmin/Tools/config_c.py", line 521, in run_c_code
    o = bld(features=kw['features'], source=test_f_name, target='testprog')
  File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 343, in __call__
    return TaskGen.task_gen(*k, **kw)
  File "/usr/local/bin/../lib/node/wafadmin/TaskGen.py", line 118, in __init__
    self.env = self.bld.env.copy()
AttributeError: 'NoneType' object has no attribute 'copy'
npm ERR! forced, continuing Error: node-expat@1.4.0 install: `node-waf configure build`
npm ERR! forced, continuing `sh "-c" "node-waf configure build"` failed with 1
npm ERR! forced, continuing     at ChildProcess.<anonymous> (/home/xxx/Downloads/package/lib/utils/exec.js:49:20)
npm ERR! forced, continuing     at ChildProcess.emit (events.js:67:17)
npm ERR! forced, continuing     at ChildProcess.onexit (child_process.js:192:12)

posted on 2011-09-16 11:37  -Anny-  阅读(646)  评论(0编辑  收藏  举报