Umair Shah Yousafzai Umair Shah Yousafzai - 6 months ago 11
Node.js Question

Can anyone let me know why am I getting this error?

I am just starting to learn

ReactJS
with
NodeJS
and trying to run an application through
NPM
but just right on start I am getting the following error as :

You MUST specify an outfile with -o.


My Starting Command :

watchify src/main.jsx -v -t [ babelify --presets [ react ]] -o public/js/main.js


Whole Error :

C:\Users\Umair Shah Yousafzai\react-skeleton>npm start

> react-skeleton@1.0.0 start C:\Users\Umair Shah Yousafzai\react-skeleton
> watchify src/main.jsx -v -t [ babelify --presets [ react ]] -o public/js/main.js

You MUST specify an outfile with -o.

npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! react-skeleton@1.0.0 start: watchify src/main.jsx -v -t [ babelify --presets [ react ]] -o public/js/main.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-skeleton@1.0.0 start script 'watchify src/main.jsx -v -t [ babelify --presets [ react ]] -o public/js/main.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-skeleton package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! watchify src/main.jsx -v -t [ babelify --presets [ react ]] -o public/js/main.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs react-skeleton
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls react-skeleton
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Umair Shah Yousafzai\react-skeleton\npm-debug.log


MY EFFORT TO SOLVE IT :

I have tried removing
node_modules
folder and then running back
npm install
but still I am getting the same error And my
NPM
Version is 3.8.9

My Files :

main.jsx
:

var React = require('react');
var ReactDOM = require('react-dom');
var List = require('./components/List.jsx');

ReactDOM.render(<List />, document.getElementById('ingredients'));


List.jsx
:

var React = require('react');
var Listitem = require('./Listitem.jsx');

var ingredients = [{"id":1,"text":"ham"},{"id":2,"text":"cheese"},{"id":3,"text":"potatos"}];

var List = React.createClass({
render: function() {
var listItems = ingredients.map(function(item) {
return <Listitem key={item.id} ingredient={item.text} />
});
return (<ul>{listItems}</ul>);
}

});

module.exports = List;


Listitem.jsx
:

var React = require('react');
var Listitem = React.createClass({
render: function() {
return (
<li>
<h4>{this.props.ingredient}</h4>
</li>
);
}

});

module.exports = ListItem;

Answer

Try to put -o {src} as the very first option; the -t option's subargument syntax may mess here.

watchify src/main.jsx -o public/js/main.js -v -t [ babelify --presets [ react ]]

Also, you need to fix your jsx files.

main.jsx:

ReactDOM.render("<List />", document.getElementById('ingredients'));

List.jsx :

return "<Listitem key={item.id} ingredient={item.text} />"

return "<ul>{listItems}</ul>";

Listitem.jsx :

return "<li><h4>{this.props.ingredient}</h4></li>";