Yeoman composeWith 找不到模块
Yeoman composeWith cannot find module
真的被这个难住了。
我写了一个生成器,里面还有其他的生成器。
当我使用 npm link 从我的本地副本安装它时,composewith 工作正常,但是当我从 github 安装生成器时,我收到错误找不到模块。
我的 compose with 函数如下所示:
this.composeWith("rawnet:static", {
options: {
appname: this.appname,
git: this.git,
gruntPath: this.sourceRoot()
}
}, {
local: require.resolve('../static')
});
我的文件夹结构如下所示:
-app
-index.js
-static
-index.js
我得到的错误是:
events.js:160
throw er; // Unhandled 'error' event
^
Error: Cannot find module '../static'
at Function.Module._resolveFilename (module.js:440:15)
at Function.resolve (internal/module.js:27:19)
at module.exports.generators.Base.extend.generateSite (/usr/local/lib/node_modules/generator-rawnet/app/index.js:79:24)
at /usr/local/lib/node_modules/generator-rawnet/node_modules/yeoman-generator/lib/base.js:421:16
at tryOnImmediate (timers.js:543:15)
at processImmediate [as _immediateCallback] (timers.js:523:5)
有没有其他人反对这个,我不明白为什么当我 运行 从本地生成器时它工作正常,但是一旦我使用 npm 从 github 安装它它失败。我检查了所有路径,它们都是正确的,我什至在 npm 安装生成器后将其更改为指向正确的文件夹,但它仍然无法正常工作。
如有任何帮助,我们将不胜感激!
好吧,在整夜拔草之后,今天早上重新审视了关于创建生成器的 yeoman 文档,我弄清楚了问题所在。
我没有将我的子生成器包含在 package.json
的 files
数组中。
真的被这个难住了。 我写了一个生成器,里面还有其他的生成器。
当我使用 npm link 从我的本地副本安装它时,composewith 工作正常,但是当我从 github 安装生成器时,我收到错误找不到模块。
我的 compose with 函数如下所示:
this.composeWith("rawnet:static", {
options: {
appname: this.appname,
git: this.git,
gruntPath: this.sourceRoot()
}
}, {
local: require.resolve('../static')
});
我的文件夹结构如下所示:
-app
-index.js
-static
-index.js
我得到的错误是:
events.js:160
throw er; // Unhandled 'error' event
^
Error: Cannot find module '../static'
at Function.Module._resolveFilename (module.js:440:15)
at Function.resolve (internal/module.js:27:19)
at module.exports.generators.Base.extend.generateSite (/usr/local/lib/node_modules/generator-rawnet/app/index.js:79:24)
at /usr/local/lib/node_modules/generator-rawnet/node_modules/yeoman-generator/lib/base.js:421:16
at tryOnImmediate (timers.js:543:15)
at processImmediate [as _immediateCallback] (timers.js:523:5)
有没有其他人反对这个,我不明白为什么当我 运行 从本地生成器时它工作正常,但是一旦我使用 npm 从 github 安装它它失败。我检查了所有路径,它们都是正确的,我什至在 npm 安装生成器后将其更改为指向正确的文件夹,但它仍然无法正常工作。
如有任何帮助,我们将不胜感激!
好吧,在整夜拔草之后,今天早上重新审视了关于创建生成器的 yeoman 文档,我弄清楚了问题所在。
我没有将我的子生成器包含在 package.json
的 files
数组中。