簡體   English   中英

部署到Heroku時在grunt上找不到模塊

[英]Cannot find module on grunt when deploying to Heroku

這真的讓我感到困惑。 基本上,我設置了一個將Grunt用於Web應用程序的Go應用程序。

我已經將https://github.com/ddollar/heroku-buildpack-multi用於我的buildpack來組合nodejs和go buildpack,但我無法使nodejs buildpack正常工作。

我設法安裝了grunt,在執行我的grunt任務時,它只是無法獲取模塊。 來自Heroku的輸出如下:

Fetching repository, done.
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 1.23 KiB | 0 bytes/s, done.
Total 10 (delta 6), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
=====> Detected Framework: Node.js
-----> Requested node range:  0.10.x
-----> Resolved node version: 0.10.30
-----> Downloading and installing node
-----> Exporting config vars to environment
-----> Installing dependencies
               npm WARN optional dep failed, continuing fsevents@0.2.0

       > blat@0.0.0 postinstall /tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d
       > echo postinstall time ls react; ls ./node_modules/react; echo AAA; ./node_modules/grunt-cli/bin/grunt heroku:deploy

       postinstall time ls react

       README.md
       addons.js
       dist
       lib
       node_modules
       package.json
       react.js

       AAA

       Loading "Gruntfile.js" tasks...ERROR
       >> Error: Cannot find module 'React'
       Warning: Task "heroku:deploy" not found. Use --force to continue.

       Aborted due to warnings.

       npm ERR! blat@0.0.0 postinstall: `echo postinstall time ls react; ls ./node_modules/react; echo AAA; ./node_modules/grunt-cli/bin/grunt heroku:deploy`
       npm ERR! Exit status 3
       npm ERR!
       npm ERR! Failed at the blat@0.0.0 postinstall script.
       npm ERR! This is most likely a problem with the blat package,
       npm ERR! not with npm itself.
       npm ERR! Tell the author that this fails on your system:
       npm ERR!     echo postinstall time ls react; ls ./node_modules/react; echo AAA; ./node_modules/grunt-cli/bin/grunt heroku:deploy
       npm ERR! You can get their info via:
       npm ERR!     npm owner ls blat
       npm ERR! There is likely additional logging output above.
       npm ERR! System Linux 3.8.11-ec2
       npm ERR! command "/tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d/vendor/node/bin/node" "/tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d/vendor/node/bin/npm" "install" "--userconfig" "/tmp/build_7d4b99cb-602b-42ee-9
a85-8b929a54646d/.npmrc" "--production"
       npm ERR! cwd /tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d
       npm ERR! node -v v0.10.30
       npm ERR! npm -v 1.4.21
       npm ERR! code ELIFECYCLE
       npm ERR!
       npm ERR! Additional logging details can be found in:
       npm ERR!     /tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d/npm-debug.log
       npm ERR! not ok code 0

請注意,我故意調用ls ./node_modules/react來查看它是否已安裝。 但是由於某種原因,它無法在我的節點文件中找到它。

我的Gruntfile:

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-react')
  grunt.loadNpmTasks('grunt-browserify')

  // doing this for testing - fails on heroku
  var react= require('React')

  grunt.initConfig({
    browserify: {
      options: {
        transform: [require('grunt-react').browserify]
      },
      app: {
        src: 'src/app.react.js',
        dest: 'public/index.js'
      }
    },
  })

  grunt.registerTask('heroku:deploy', [
    'browserify:app'
  ])
}

和package.json文件:

{
  "name": "blat",
  "version": "0.0.0",
  "description": "",
  "engines": {
    "node": "0.10.x",
    "npm": "1.4.x"
  },
  "dependencies": {
    "director": "^1.2.3",
    "es6-promise": "^1.0.0",
    "grunt": "^0.4.5",
    "grunt-cli": "^0.1.13",
    "grunt-react": "^0.9.0",
    "react": "^0.11.1",
    "react-router": "^0.5.2",
    "superagent": "^0.18.2",
    "superagent-prefix": "0.0.2"
  },
  "devDependencies": {},
  "scripts": {
    "postinstall": "echo postinstall time; ./node_modules/grunt-cli/bin/grunt heroku:deploy"
  }
}

.buildpacks

https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/kr/heroku-buildpack-go.git

Heroku配置:

BUILDPACK_URL = https://github.com/ddollar/heroku-buildpack-multi.git
NODE_ENV = production

有人知道問題出在哪里嗎? 我無法在本地復制它,這真令人沮喪。 我已經嘗試過https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt buildpack,但是它給了我相同的結果。

好的,這是區分大小寫的問題。 顯然我使用的是HFS +不區分大小寫的格式,這解釋了為什么我的代碼在本地工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM