【问题标题】:Grunt error SailsJS when lifting with --no-frontend使用 --no-frontend 提升时出现 Grunt 错误 SailsJS
【发布时间】:2016-03-04 12:50:39
【问题描述】:

我有一个 Sails Api,它第一次启动就像一个魅力。 按 CTRL + C 停止它,然后尝试再次启动它。它有效,但是,

error: ** Grunt :: An error occurred. **
error: 
------------------------------------------------------------------------
Aborted due to warnings.
Running "clean:dev" (clean) task
Warning: Cannot delete files outside the current working directory. 
------------------------------------------------------------------------

error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.

error: Troubleshooting tips:
error: 
error:  *-> Are "grunt" and related grunt task modules installed locally?  Run `npm install` if you're not sure.
error: 
error:  *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error: 
error:  *-> Or maybe you don't have permissions to access the `.tmp` directory?
error:      e.g., `folderthingy` ?
error: 
error:      If you think this might be the case, try running:
error:      sudo chown -R 501 folderthingy

好吧,我检查了所有内容,该文件夹是我自己的并且有足够的权限。我还安装了 777 用于测试目的,但这并没有改变任何事情。

然后,我决定清除 .tmp 文件夹的所有内容并尝试重新启动。这就像一个魅力,.tmp 再次被填充,当我停止服务器,尝试重新启动它时,我再次收到完全相同的错误消息!

我正在使用 --no-frontend 选项启动,所以实际上我不明白它为什么要加载 grunt。

为什么会这样?这里出了什么问题?

【问题讨论】:

标签: gruntjs sails.js


【解决方案1】:

人类仍然不知道它为什么会发生,但我通过删除 Gruntfile 修复了它。

【讨论】:

    【解决方案2】:

    通过以下步骤解决了这个问题:

    sails 应用中的文件路径 -> tasks/config/sync.js

    // 1. Install it as a local dependency of your Sails app:
    //    ```
    //    $ npm install grunt-sync --save-dev --save-exact
    //    ```
    //
    //
    // 2. Then uncomment the following code:
    //
    // ```
    // // Load Grunt plugin from the node_modules/ folder.
    // grunt.loadNpmTasks('grunt-sync');
    // ```
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    

    注意:未找到警告“sync:dev”的工作

    【讨论】:

      【解决方案3】:

      如果您使用的是 Linux,请尝试使用sudo sails lift,您可能会遇到权限问题(发生在我身上)。如果 Windows - 检查是否没有文件管理器或其他程序阻止 .tmp 文件夹(当我在 Total Commander 中打开文件夹时也发生过)。 在任何情况下,由于您不使用前端,您可以简单地删除一些 grunt 任务(在文件夹 tasks/ 你有 README.md ,它解释了在哪种情况下运行哪些任务)或所有任务(参见 @987654321 @),你不会有问题。

      【讨论】:

      • 我使用 MacOsx,我想知道为什么会弹出错误 :)
      • options: { force: true },可以在tasks/config/clean.js中设置。哪个解决了问题
      • @cfl 对我所描述的情况没有帮助
      【解决方案4】:

      我也遇到了这个错误-

      error: ** Grunt :: An error occurred. **
      error: 
      ------------------------------------------------------------------------
      Aborted due to warnings.
      Running "sass:dev" (sass) task
      
          > error: Looks like a Grunt error occurred--
          > 
          > error: Please fix it, then **restart Sails** to continue running tasks
          > (e.g. watching for changes in assets)
          > 
          > error: Or if you're stuck, check out the troubleshooting tips below.
      
      error: Troubleshooting tips:
      error: 
      error:  *-> Are "grunt" and related grunt task modules installed locally?  Run `npm install` if you're not sure.
      error: 
      error:  *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
      error: 
      error:  *-> Or maybe you don't have permissions to access the `.tmp` directory?
      error:      e.g., `/Users/siyaram.malav/Desktop/repo/project1/.tmp` ?
      

      出现此错误是因为它找不到 sass 模块。并运行以下命令

      sudo gem install sass

      它对我有用。

      在您的情况下,请尝试运行 sudo gem install clean 命令。

      它应该工作。 谢谢。

      【讨论】:

        【解决方案5】:

        我在学习本教程时遇到了同样的问题: https://www.youtube.com/watch?v=ZE7ye2G_H9Q&index=4&list=PLf8i4fc0zJBzLhOe6FwHpGhBDgqwInJWZ

        我创建了一个“链接器”文件夹,因为这就是那个人所做的,然后提示我错误。看起来他正在使用旧版本的 SailsJS,因为他没有遇到任何错误。

        您是否偶然在资产文件夹中创建了一个新文件夹?如果你这样做了,问题是 grunt 无法在特定文件夹上运行任务,因为它没有与 assets 文件夹和文件的其余部分链接。尝试将所有新创建的文件放在现有文件夹中,然后重试。这对我有用。

        【讨论】:

        • 不,我没有。修复了它,删除了 gruntfile
        猜你喜欢
        • 2014-11-05
        • 2018-01-25
        • 2013-01-01
        • 1970-01-01
        • 2014-06-23
        • 2022-08-16
        • 2017-02-04
        • 1970-01-01
        • 2014-01-25
        相关资源
        最近更新 更多