【发布时间】:2015-09-05 19:11:16
【问题描述】:
所以,我最近一直在玩DocPad;我已经完成了本教程,并且所有内容都已安装并正常工作,除了...
为了了解 DocPad 如何与更大的站点一起工作,我从 github 获取了 Jason Young (http://ytechie.com) 站点的代码(为什么是这个站点?这是我第一次听说 DocPad 的地方)。根据说明,我执行了npm install(还没有问题);然后docpad run。它返回此错误:
C:\Users\harnerd\Documents\GitHub\ytechie-docpad>docpad run
error: undefined 'C:\\Users\\harnerd\\.docpad.cson'
error: null
error: null
TypeError: undefined is not a function
at Object.exports.eval (C:\Users\harnerd\Documents\GitHub\ytechie- docpad\node_modules\coffee-script\lib\coffee-script\coffee-script.js:120:47)
at Object.CSON.parseSync (C:\Users\harnerd\Documents\GitHub\ytechie-docpad\node_modules\docpad\node_modules\cson\out\lib\cson.js:90:34)
at null._onTimeout (C:\Users\harnerd\Documents\GitHub\ytechie-docpad\node_modules\docpad\node_modules\cson\out\lib\cson.js:70:24)
at Timer.listOnTimeout (timers.js:119:15)
info: null
鉴于我是 DocPad 的新手,我可能缺少一些简单而明显的东西,但我不知道是什么。我必须承认,当出现问题时,DocPad 有点难以理解。在我看来,它在抱怨找不到 .docpad.cson 文件,但它确实存在于错误消息中引用的位置。
我完全误解了这个错误的含义,还是什么?我在 Windows 7 上运行 node.js v0.12.7 和 docpad v6.54.2。
编辑:这是我的 .docpad.cson 文件的内容:
name: "MAC 6a85329428c35b394e921ec0cb3298eed2a1b707"
email: null
username: "6a85329428c35b394e921ec0cb3298eed2a1b707"
subscribed: false
subscribeTryAgain: null
tos: true
identified: true
这里没有什么神奇的。在 balupton 的建议下,我通过 coffeescript “Try CoffeeScript” 编译器运行它,但不出所料,它只是生成了一些 JSON。
编辑 2: 尝试 Benjamin 在评论中的建议,我运行了 npm install -g docpad,运行成功。然后我在项目中运行docpad update --global 并获得了以下奖励:
C:\Users\harnerd\Documents\GitHub\ytechie-docpad>docpad update --global
info: Welcome to DocPad v6.78.3 (global installation: C:\Users\harnerd\AppData\Roaming\npm\node_modules\docpad)
notice: If everyone who saw this message donated $1/week, maintaining DocPad would become sustainable: http://docpad.org/donate
info: Contribute: http://docpad.org/docs/contribute
info: Plugins: cleanurls, coffeescript, dateurls, eco, less, livereload, marked, paged, partials, sitemap, tagging
info: Environment: development
info: Cleaning files
info: Cleaned files
\
> typechecker@2.0.8 preinstall C:\Users\harnerd\Documents\GitHub\ytechie- docpad\node_modules\docpad-plugin- sitemap\node_modules\extendr\node_modules\typechecker
> node ./cyclic.js
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "docpad@6" "docpad-p
lugin-marked@2" "docpad-plugin-eco@2" "docpad-plugin-less@2" "docpad-plugin- partials@2" "docpad-plugin-coffeescript@2" "docpad-plugin-sitemap@2" "--save"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path C:\Users\harnerd\Documents\GitHub\ytechie- docpad\node_modules\docpad-plugin-partials
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! Error: EPERM, lstat 'C:\Users\harnerd\Documents\GitHub\ytechie- docpad\node_modules\docpad-plugin-partials'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM, lstat 'C:\Users\harnerd\Documents\GitHub\ytechie- docpad\node_modules\docpad-plugin-partials']
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! path: 'C:\\Users\\harnerd\\Documents\\GitHub\\ytechie- docpad\\node_modules\\docpad-plugin-partials' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\harnerd\Documents\GitHub\ytechie-docpad\npm-debug.log
error: The action completed successfully
error: An error occured:
Error: Command exited with a non-zero status code.
at Object.safeps.prepareExecutableResult (C:\Users\harnerd\AppData\Roaming\npm\node_modules\docpad\node_modules\safeps\ou t\lib\safeps.js:190:24)
at ChildProcess.<anonymous> (C:\Users\harnerd\AppData\Roaming\npm\node_modules\docpad\node_modules\safeps\ou t\lib\safeps.js:322:29)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
To report the above, follow the guide at: http://docpad.org/bug-report
Error: Command exited with a non-zero status code.
at Object.safeps.prepareExecutableResult (C:\Users\harnerd\AppData\Roaming\npm\node_modules\docpad\node_modules\safeps\ou t\lib\safeps.js:190:24)
at ChildProcess.<anonymous> (C:\Users\harnerd\AppData\Roaming\npm\node_modules\docpad\node_modules\safeps\ou t\lib\safeps.js:322:29)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
C:\Users\harnerd\Documents\GitHub\ytechie-docpad>
尽管 npm 声称,我以管理员身份运行;然而,真正的问题不在于 npm 没有对 docpad-plugin-partials 文件夹的权限——它根本无法找到它,因为它已被删除。
当我最初在项目上运行 npm install 时,package.json 中列出的所有依赖项都是在 node_modules 文件夹中创建的,但是当我运行 docpad update --global 时,docpad-plugin-partials 文件夹被删除了。
为了看看我是否可以重复这种行为,我又两次抓取了该网站的原始代码。每次我运行 npm install(没问题 - 所有依赖项在 node_modules 中都有自己的文件夹),然后是 docpad run(与 .docpad.cson 文件有相同的问题),最后是 docpad update --global。依赖文件夹已从 node_modules 文件夹中删除,但不再是相同的。
编辑 3: 传奇仍在继续。尽管绝对没有任何改变,但在执行docpad update --global 时文件丢失和保持丢失的奇怪问题已经消失,我又回到了原来的问题 (error: undefined 'C:\\Users\\harnerd\\.docpad.cson)。不知道我本地环境中的某些东西是否有问题,或者我抓到的body of code 是否有问题。我怀疑是后者。
【问题讨论】:
-
正如我所提到的,我是 DocPad 的新手,但如果有人用枪指着我的头让我猜测这个问题的答案,我会说我有预感与最初用于构建 ytechie 站点的组件和我现在系统上的组件之间的版本差异有关。但这可能是一个完全的红鲱鱼。
-
感谢您更新问题的详细信息 - 看来您的假设是正确的 - 如果您运行
npm install -g docpad以获取全局安装的最新 docpad 版本,然后在项目中运行docpad update --global以更新它docpad依赖到最新,然后运行docpad run再试一次,会发生什么? -
最新的更新很有趣,不确定是什么导致了这些权限问题,无论是环境问题,还是 docpad 问题。要找出答案,让我们试试这个。失败的命令是
docpad update --global执行这个命令的时候:npm install --save docpad@6 docpad-plugin-marked@2 docpad-plugin-eco@2 docpad-plugin-less@2 docpad-plugin-partials@2 docpad-plugin-coffeescript@2 docpad-plugin-sitemap@2如果你删除了node_modules目录,然后运行npm install,然后直接运行那个命令,再运行docpad run行不行? -
当我这样做时,文件夹已正确创建。但是,正如我刚刚在上面添加的那样,无论如何,现在一般情况下都会发生这种情况。我现在回到原来的问题。我很乐意帮助诊断这个问题,因为它似乎是一个边缘情况,即 docpad 无法正确处理我的环境或我要求它处理的特定代码体。在github bug report 继续工作会更有意义吗?