redux-webpack-es6-boilerplate
redux-webpack-es6-boilerplate copied to clipboard
npm run test - SyntaxError: Unexpected token import
Pulled the project down and everything is working great so far. However, npm run test
is :boom: .
All of the other commands before that in the ReadMe are fine, build
, build:serve
, npm start
. But when I get to the test, no luck.
console error
$ npm run test
> [email protected] test C:\projects\git-stats
> mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit
C:\projects\git-stats\test\unit\testHelper.js:1
(function (exports, require, module, __filename, __dirname) { import jq from 'jquery';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at loader (C:\projects\git-stats\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\projects\git-stats\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at C:\projects\git-stats\node_modules\mocha\bin\_mocha:310:3
at Array.forEach (native)
at Object.<anonymous> (C:\projects\git-stats\node_modules\mocha\bin\_mocha:309:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit'.
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 git-stats package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs git-stats
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls git-stats
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\projects\git-stats\npm-debug.log
npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'test' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle [email protected]~pretest: [email protected]
6 silly lifecycle [email protected]~pretest: no script for pretest, continuing
7 info lifecycle [email protected]~test: [email protected]
8 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~test: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\projects\git-stats\node_modules\.bin;C:\cmder\bin;C:\cmder\vendor\conemu-maximus5\ConEmu\Scripts;C:\cmder\vendor\conemu-maximus5;C:\cmder\vendor\conemu-maximus5\ConEmu;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\CCM;C:\Windows\CCM;C:\Windows\CCM;C:\Windows\CCM;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn;C:\Program Files\Microsoft\Web Platform Installer;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn;C:\Program Files (x86)\Yarn\bin;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files\Microsoft SQL Server\120\DTS\Binn;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\WindowsPowerShell\v1.0;C:\ProgramData\chocolatey\lib\eh.flyway.commandline\tools\flyway-4.2.0;C:\ProgramData\chocolatey\lib\eh.flyway.commandline\tools\flyway-4.2.0\drivers;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Ruby193\bin;C:\Users\domipe\AppData\Local\atom\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\domipe\AppData\Local\Yarn\.bin;C:\phantomjs-2.1.1-windows\bin;C:\Program Files\Docker Toolbox;C:\Users\domipe\AppData\Roaming\npm;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\share\vim\vim74;C:\cmder
10 verbose lifecycle [email protected]~test: CWD: C:\projects\git-stats
11 silly lifecycle [email protected]~test: Args: [ '/d /s /c',
11 silly lifecycle 'mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit' ]
12 silly lifecycle [email protected]~test: Returned: code: 1 signal: null
13 info lifecycle [email protected]~test: Failed to exec test script
14 verbose stack Error: [email protected] test: `mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:891:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd C:\projects\git-stats
17 error Windows_NT 6.1.7601
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
19 error node v6.11.0
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error [email protected] test: `mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit`
22 error Exit status 1
23 error Failed at the [email protected] test script 'mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the git-stats package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error mocha --compilers js:babel-core/register,css:./test/unit/cssNullCompiler.js --require ./test/unit/testHelper.js --recursive ./test/unit
23 error You can get information on how to open an issue for this project with:
23 error npm bugs git-stats
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls git-stats
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
There are multiple problems here. The one referenced above is caused by this line in .babelrc
:
["es2015", { "modules": false }]
specifically, the "modules" setting. If you remove the { "modules": false }
or use { "modules": "commonjs" }
the es6 syntax error will go away.
However, you will then get errors about missing files:
Error: Cannot find module '../../../src/js/constants/ActionTypes' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.
(/redux-webpack-es6-boilerplate/test/unit/actions/FriendsActionsSpec.js:2:1)
Looks like some code was moved around.