ubuntu - gruntjs 的基本安装问题 - 与 Bootstrap 一起使用

标签 ubuntu twitter-bootstrap-3 gruntjs

为模糊的标题道歉 - 不知道怎么说。

基本上,我在使用 grunt 时遇到了问题。几周前,我安装了 Bootstrap 源代码和 Grunt。当我运行 grunt 时一切正常,我的 LESS 已编译为 CSS。

几天前我回到了同样的安装,但 Grunt 没有执行。它甚至没有尝试编译任何 LESS 文件,我遇到了有关 Grunt 丢失和/或未满足依赖项的消息(尽管我的 NPM 和 nodejs 在我的用户帐户和 root 上都是最新的)。我没有多想,决定重新安装 grunt,但无济于事。

现在我刚刚完全删除了 public_html 下的 bootstrap 目录。然后我从 Github 克隆。我检查了克隆的存储库,一切看起来都不错,它甚至包括一个名为“grunt”的文件夹,下面是 Gruntfile.js。我假设这来自 Git 克隆,这非常有用,但最终还是无法正常工作。

我运行 grunt 并遇到...

module.js:340
throw err;
      ^
Error: Cannot find module 'coffee-script'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous>(/var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/lib/grunt.js:16:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

然后我运行 npm install 尝试安装基于 package.json 的正确依赖项,但我遇到了......

npm WARN prefer global grunt-cli@0.1.13 should be installed with -g
npm WARN unmet dependency /var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/node_modules/findup-sync requires glob@'~3.2.9' but will load
npm WARN unmet dependency /var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/node_modules/glob,
npm WARN unmet dependency which is version 3.1.21
npm WARN unmet dependency /var/www/andrewtanner.me/public_html/bootstrap/node_modules/grunt/node_modules/findup-sync requires lodash@'~2.4.1' but will load

(我已将其截断以保存滚动)

我在这里完全不知所措。我正在运行 npm 1.4.6 和 nodejs 0.10.26,所以我不知道 Grunt 不会运行什么,特别是考虑到我之前已经运行它没有问题。

更新:我现在正在使用 Ubuntu 14.04(以前的 12.04),并且在运行 npm install 时收到此消息。上面的错误不再出现,但常见的主题是 Grunt 仍然没有安装/工作。

phantomjs@1.9.7-5 install /var/www/dev.andrewtanner.me/public_html/bootstrap/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs node install.js sh: 1: node: not found npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! weird error 127 npm ERR! not ok code 0

为什么这比它需要的更复杂?

非常感谢任何帮助 - 谢谢。

最佳答案

我在 Ubuntu 14.04 和 Bootstrap 3.2.0 上遇到了同样的问题。就我而言,问题已通过安装 node.js 兼容包得到解决:

sudo apt-get install nodejs-legacy

之后我再次运行 npm install,它成功了。

注意:

在再次运行 npm install 之前,不要忘记删除 node_modules 文件夹,因为先前失败的安装可能使其处于不一致状态。

我在像这样运行 grunt dist 时出错:

Loading Gruntfile.js...^^^ERROR
Error: Cannot find module 'error/validation'

删除 node_modules 文件夹并再次运行 npm install 已解决这些问题。

关于ubuntu - gruntjs 的基本安装问题 - 与 Bootstrap 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23285056/

相关文章:

html - 图像叠加在响应大小的图像 Bootstrap 上

css - 编译bootstrap compass文件时如何更改路径

node.js - 使用 Grunt-babelify-browserify 而不导入 Node 模块

ubuntu - 我刚刚安装了 Ubuntu 20.04 LTS,默认密码是什么?

css - 仅将 CSS 应用于非折叠菜单

html - 如何在 Bootstrap 中将背景图像放置到容器的两侧?

css - 如何使用 Yeoman 的 Grunt.js 文件启用 SASS lineNumbers?

python - 如何在 Ubuntu/Apache 中使用 crontab 运行 python 脚本

php - 无法在新服务器上执行 Ajax 查询

linux - OS.File set chown 和 chmod (创建可信启动器 - ubuntu)