生成webapp时未定义Yo错误编码

时间:2014-02-16 12:58:28

标签: yeoman yeoman-generator

我在跟随http://www.youtube.com/watch?feature=player_embedded&v=zBt2g9ekiug到约3分钟之后从cmd行运行yo webapp时得到以下内容。有没有人见过这个?

   C:\Users\L\AppData\Roaming\npm\node_modules\generator-webapp\node_modules\cheeri
o\node_modules\entities\index.js:36
        return encode[level](data);
               ^
ReferenceError: encode is not defined
    at Object.exports.encode (C:\Users\L\AppData\Roaming\npm\node_modules\genera
tor-webapp\node_modules\cheerio\node_modules\entities\index.js:36:9)
    at exports.encode (C:\Users\L\AppData\Roaming\npm\node_modules\generator-web
app\node_modules\cheerio\lib\utils.js:41:50)
    at formatAttrs (C:\Users\L\AppData\Roaming\npm\node_modules\generator-webapp
\node_modules\cheerio\lib\render.js:30:32)
    at renderTag (C:\Users\L\AppData\Roaming\npm\node_modules\generator-webapp\n
ode_modules\cheerio\lib\render.js:113:18)
    at C:\Users\L\AppData\Roaming\npm\node_modules\generator-webapp\node_modules
\cheerio\lib\render.js:81:17
    at Array.forEach (native)
    at Function._.each._.forEach (C:\Users\L\AppData\Roaming\npm\node_modules\ge
nerator-webapp\node_modules\cheerio\node_modules\underscore\underscore.js:79:11)

    at module.exports (C:\Users\L\AppData\Roaming\npm\node_modules\generator-web
app\node_modules\cheerio\lib\render.js:77:5)
    at Object.exports.html (C:\Users\L\AppData\Roaming\npm\node_modules\generato
r-webapp\node_modules\cheerio\lib\static.js:40:12)
    at Appgenerator.domUpdate (C:\Users\L\AppData\Roaming\npm\node_modules\gener
ator-webapp\node_modules\yeoman-generator\lib\actions\wiring.js:44:14)

5 个答案:

答案 0 :(得分:6)

在使用最新Yomen版本的教程时遇到同样的问题。 实体库中存在拼写错误您可以手动修复以完成教程:

打开包含错误的文件(在您的情况下为C:\ Users \ L \ AppData \ Roaming \ npm \ node_modules \ generator-webapp \ node_modules \ cheerio \ node_modules \ entities \ index.js)并将变量名称从inverse更改为encode

var decode = levels.map(function(l){ return l.normal; }),
    decodeStrict = levels.map(function(l){ return l.strict; }),
    inverse = levels.map(function(l){ return l.inverse; });

var decode = levels.map(function(l){ return l.normal; }),
    decodeStrict = levels.map(function(l){ return l.strict; }),
    encode = levels.map(function(l){ return l.inverse; });

答案 1 :(得分:3)

一种解决方法是使用cg-angular yeoman生成器:

sudo npm install -g generator-cg-angular
yo cg-angular

如果您正在学习教程,那么显然不理想。

答案 2 :(得分:1)

在OSX中也发生角度生成器:

/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/node_modules/entities/index.js:36
    return encode[level](data);
           ^
ReferenceError: encode is not defined
at Object.exports.encode (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/node_modules/entities/index.js:36:9)
at exports.encode (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/lib/utils.js:41:50)
at formatAttrs (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/lib/render.js:30:32)
at renderTag (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/lib/render.js:114:18)
at /usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/lib/render.js:82:17
at Array.forEach (native)
at Function._.each._.forEach (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/node_modules/underscore/underscore.js:78:11)
at module.exports (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/lib/render.js:78:5)
at Object.exports.html (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/cheerio/lib/static.js:40:12)
at Generator.domUpdate (/usr/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/lib/actions/wiring.js:39:14)

答案 3 :(得分:0)

Node模块实体刚刚发布了一个新版本,打破了yeoman的依赖(cheerio)。

答案 4 :(得分:0)

错误似乎源于cheerio。问题在此处开始https://github.com/MatthewMueller/cheerio/pull/382