jestのチュートリアルで躓いた話
はじめに
jestを覚えたいと思った。
チュートリアルを実行した。
いきなりエラーが発生した。
npmのバージョン
❯ npm -v
5.6.0
構成
❯ mkdir jest-spike
❯ cd jest-spike
❯ npm init
❯ npm install --save-dev jest
❯ vim sum.js (サンプルの通り)
❯ vim sum.test.js (サンプルの通り)
❯ vim package.json (サンプルの通り)
エラーの内容
❯ npm test
> [email protected] test /Users/xx/workspace/jest-spike
> jest
/Users/xx/workspace/jest-spike/node_modules/jest/node_modules/jest-cli/build/cli/index.js:227
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/xx/workspace/jest-spike/node_modules/jest/node_modules/jest-cli/bin/jest.js:16:3)
npm ERR! Test failed. See above for more details.
原因
❯ npm -v
5.6.0
❯ mkdir jest-spike
❯ cd jest-spike
❯ npm init
❯ npm install --save-dev jest
❯ vim sum.js (サンプルの通り)
❯ vim sum.test.js (サンプルの通り)
❯ vim package.json (サンプルの通り)
エラーの内容
❯ npm test
> [email protected] test /Users/xx/workspace/jest-spike
> jest
/Users/xx/workspace/jest-spike/node_modules/jest/node_modules/jest-cli/build/cli/index.js:227
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/xx/workspace/jest-spike/node_modules/jest/node_modules/jest-cli/bin/jest.js:16:3)
npm ERR! Test failed. See above for more details.
原因
❯ npm test
> [email protected] test /Users/xx/workspace/jest-spike
> jest
/Users/xx/workspace/jest-spike/node_modules/jest/node_modules/jest-cli/build/cli/index.js:227
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/xx/workspace/jest-spike/node_modules/jest/node_modules/jest-cli/bin/jest.js:16:3)
npm ERR! Test failed. See above for more details.
nodeのバージョンが古すぎた。
yarnでjest入れたらこんなエラー出た。
error [email protected]: The engine "node" is incompatible with this module. Expected version ">= 10.14.2". Got "8.11.1"
error Found incompatible module.
nodeをv8.11.1からv14.8.0に上げたら動いた。
Author And Source
この問題について(jestのチュートリアルで躓いた話), 我々は、より多くの情報をここで見つけました https://qiita.com/msuzuki/items/054fce7f77eaf7ad7ebc著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .