Lodash-es is not working with mocha and babel -


i created simple workspace demonstrate problem:

.babelrc:

{   "presets": ["es2015"] } 

package.json

{   "name": "mocha-demo",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "mocha --compilers js:babel-register"   },   "author": "",   "license": "isc",   "dependencies": {     "babel-preset-es2015": "^6.24.1",     "babel-register": "^6.26.0",     "lodash-es": "^4.17.4",     "mocha": "^3.5.3"   } } 

test/index.test.js

import {describe, it} "mocha"; import {clonedeep} "lodash-es";  describe("index", () => {     it("should work", () => {         // init         const = {a: 1};         const b = clonedeep(a);          // action          // test     }); }); 

and error cannot fix:

> mocha-proba@1.0.0 test c:\...\mocha-demo > mocha --compilers js:babel-register "test"  c:\...\mocha-demo\node_modules\lodash-es\lodash.js:10 export { default add } './add.js'; ^^^^^^  syntaxerror: unexpected token export     @ createscript (vm.js:74:10)     @ object.runinthiscontext (vm.js:116:10)     @ module._compile (module.js:533:28)     @ module._extensions..js (module.js:580:10)     @ object.require.extensions.(anonymous function) [as .js] (c:\...\mocha-demo\node_modules\babel-register\lib\node.js:152:7)     @ module.load (module.js:503:32)     @ trymoduleload (module.js:466:12)     @ function.module._load (module.js:458:3)     @ module.require (module.js:513:17)     @ require (internal/module.js:11:18)     @ object.<anonymous> (c:/.../mocha-demo/test/index.test.js:2:1)     @ module._compile (module.js:569:30)     @ loader (c:\...\mocha-demo\node_modules\babel-register\lib\node.js:144:5)     @ object.require.extensions.(anonymous function) [as .js] (c:\...\mocha-demo\node_modules\babel-register\lib\node.js:154:7)     @ module.load (module.js:503:32)     @ trymoduleload (module.js:466:12)     @ function.module._load (module.js:458:3)     @ module.require (module.js:513:17)     @ require (internal/module.js:11:18)     @ c:\...\mocha-demo\node_modules\mocha\lib\mocha.js:231:27     @ array.foreach (native)     @ mocha.loadfiles (c:\...\mocha-demo\node_modules\mocha\lib\mocha.js:228:14)     @ mocha.run (c:\...\mocha-demo\node_modules\mocha\lib\mocha.js:514:10)     @ object.<anonymous> (c:\...\mocha-demo\node_modules\mocha\bin\_mocha:480:18)     @ module._compile (module.js:569:30)     @ object.module._extensions..js (module.js:580:10)     @ module.load (module.js:503:32)     @ trymoduleload (module.js:466:12)     @ function.module._load (module.js:458:3)     @ function.module.runmain (module.js:605:10)     @ startup (bootstrap_node.js:158:16)     @ bootstrap_node.js:575:3  process finished exit code 1 

what should do, fix problem? using lodash-es, because tree-shaking better this.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -