2016-01-25 20 views
7

मैं जानता हूँ कि babel-node पर ध्यान नहीं देता node_modules डिफ़ॉल्ट रूप से node_modules में jsx फ़ाइल की आवश्यकता होती है करने में विफल रहता है, तो मैं इसे ओवरराइड कर तीन अलग अलग तरीकों भाग गया, सब विफल रहा:कोलाहल नोड

:

  1. .babelrc साथ babel-node app.js भाग गया

    { 
        "presets": ["es2015", "react"], 
        "only": [ 
        "app", 
        "node_modules/react-components" 
        ] 
    } 
    

    परिणाम: आवश्यक jsx नोड मॉड्यूल के लिए SyntaxError: Unexpected token <

  2. भाग गया.babelrc साथ:

    { 
        "presets": ["es2015", "react"], 
        "ignore": "node_modules\/(?!react-components)" 
    } 
    

    परिणाम: SyntaxError: Unexpected token < jsx नोड की आवश्यकता मॉड्यूल

  3. .babelrc साथ babel-node ./bin/www --ignore '/node_modules/(?!react-components) भाग गया के लिए:

    { 
        "presets": ["es2015", "react"] 
    } 
    

    परिणाम:

    [project]/node_modules/babel-preset-react/node_modules/babel-plugin-transform-react-jsx/lib/index.js:12 
        var visitor = require("babel-helper-builder-react-jsx")({ 
                     ^
    
    TypeError: object is not a function 
    

अनदेखा विकल्प के साथ रजिस्टर हुक का उपयोग सही ढंग से काम किया।

app.js

require('babel-core/register')({ 
    ignore: /node_modules\/(?!react-components)/ 
}); 

हालांकि इस काम करता है की शुरुआत में इस कोड के साथ node app.js भाग गया, मैं अभी भी पता करने के लिए क्यों babel-node के साथ मेरी कार्यान्वयन काम नहीं करता है चाहता हूँ। धन्यवाद।


संदर्भ:

+0

कभी यह पता लगाएं? – jcreamer898

+0

@ jcreamer898 nope –

उत्तर

1

इस कोलाहल में एक ज्ञात बग है, जहां यह ध्यान नहीं देता है 01 हैऔर ignore

प्रासंगिक बग T6726 है, जो fixed in babel 6.14.0 रहा है।

संबंधित मुद्दे