मैं जानता हूँ कि babel-node
पर ध्यान नहीं देता node_modules
डिफ़ॉल्ट रूप से node_modules में jsx फ़ाइल की आवश्यकता होती है करने में विफल रहता है, तो मैं इसे ओवरराइड कर तीन अलग अलग तरीकों भाग गया, सब विफल रहा:कोलाहल नोड
.babelrc
साथbabel-node app.js
भाग गया{ "presets": ["es2015", "react"], "only": [ "app", "node_modules/react-components" ] }
परिणाम: आवश्यक jsx नोड मॉड्यूल के लिए
SyntaxError: Unexpected token <
भाग गया
.babelrc
साथ:{ "presets": ["es2015", "react"], "ignore": "node_modules\/(?!react-components)" }
परिणाम:
SyntaxError: Unexpected token <
jsx नोड की आवश्यकता मॉड्यूल.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
के साथ मेरी कार्यान्वयन काम नहीं करता है चाहता हूँ। धन्यवाद।
संदर्भ:
- How do I use babel in a node CLI program?
- import a module from node_modules with babel but failed
- http://babeljs.io/docs/usage/cli/
- http://babeljs.io/docs/usage/options/
कभी यह पता लगाएं? – jcreamer898
@ jcreamer898 nope –