Saturday 3 June 2017

npm run script error on Babel

I intend to transform JSX during build time instead of during run time. First, I installed 2 babel tools using the following commands:

$npm install --save-dev babel-cli babel-preset-react
$node_modules/.bin/babel src --presets react --out-dir static

Then in package.json, I added the following under the scripts section.

...
"scripts": {
    "compile": "babel src -presets react -out-dir static",
    "watch": "babel src -presets react -out-dir static -watch",
    "test": "echo \"Error: no test specified\" && exit 1"
},
...

My folder directory is as follows:

Mern\node_modules
Mern\src\app.jsx
Mern\static\app.js
Mern\static\index.html
Mern\package.json
Mern\server.js

When I ran the command: npm run compile, there were a series of errors.

> pro_mern_stack@1.0.0 compile         /Users/comp/Documents/mern
> babel src -presets react -out-dir static

-d doesn't exist. -i doesn't exist. -r doesn't exist

npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "compile"
npm ERR! node v7.10.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! pro_mern_stack@1.0.0 compile: `babel src -presets react -out- dir static`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the pro_mern_stack@1.0.0 compile script 'babel src -presets react -out-dir static'.
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 mern package, npm ERR! not with npm itself.

I would like to seek advice on what is missing here or is it something with the installation/configuration or folder structure ?



via Clement

No comments:

Post a Comment