Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run test - SyntaxError: Unexpected token import #55

Open
dperez3 opened this issue Sep 22, 2017 · 1 comment
Open

npm run test - SyntaxError: Unexpected token import #55

dperez3 opened this issue Sep 22, 2017 · 1 comment

Comments

@dperez3
Copy link

dperez3 commented Sep 22, 2017

Pulled the project down and everything is working great so far. However, npm run test is 馃挜 .

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

> git-stats@1.1.1 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! git-stats@1.1.1 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 git-stats@1.1.1 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 npm@3.10.10
3 info using node@v6.11.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle git-stats@1.1.1~pretest: git-stats@1.1.1
6 silly lifecycle git-stats@1.1.1~pretest: no script for pretest, continuing
7 info lifecycle git-stats@1.1.1~test: git-stats@1.1.1
8 verbose lifecycle git-stats@1.1.1~test: unsafe-perm in lifecycle true
9 verbose lifecycle git-stats@1.1.1~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 git-stats@1.1.1~test: CWD: C:\projects\git-stats
11 silly lifecycle git-stats@1.1.1~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 git-stats@1.1.1~test: Returned: code: 1  signal: null
13 info lifecycle git-stats@1.1.1~test: Failed to exec test script
14 verbose stack Error: git-stats@1.1.1 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 git-stats@1.1.1
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 git-stats@1.1.1 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 git-stats@1.1.1 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 ]
@dland512
Copy link

dland512 commented Oct 13, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants