With "jest": "^20.0.4" specified an AppVeyor build of a private repository using Node.js v8.0.0 fails:
TypeError: projects.map is not a function
at Object.<anonymous> (C:\projects\the-project\node_modules\jest-cli\build\cli\runCLI.js:112:28)
at Generator.next (<anonymous>)
at step (C:\projects\the-project\node_modules\jest-cli\build\cli\runCLI.js:1:260)
at C:\projects\the-project\node_modules\jest-cli\build\cli\runCLI.js:1:490
at Promise (<anonymous>)
at Object.<anonymous> (C:\projects\the-project\node_modules\jest-cli\build\cli\runCLI.js:1:171)
at Object.module.exports [as runCLI] (C:\projects\the-project\node_modules\jest-cli\build\cli\runCLI.js:139:50)
at Object.run (C:\projects\the-project\node_modules\jest\node_modules\jest-cli\build\cli\index.js:42:17)
at Object.<anonymous> (C:\projects\the-project\node_modules\jest\node_modules\jest-cli\bin\jest.js:16:25)
at Module._compile (module.js:569:30)
I'm seeing the same behavior locally on Windows 10. Node.js v6 in the same build passes on AppVeyor.
Same here :/ Travis worked fine but local. no chance
I ran into a similar problem. Jest ran fine via yarn global add, but failed when added locally via yarn. It weirdly worked when it was installed locally via npm npm -D jest. Maybe something weird with yarn or npm v5?
Are you sure you are using Jest 20 consistently? This has happened to me before when trying to run Jest 20 on a project that uses Jest 19.
Happening for me with jest v20.0.4 and node v6.11.0
And for what it's worth I'm on Linux, not Windows.
Installing jest globally through npm install -g jest works. The binary ./node_modules/.bin/jest however fails with the error mentioned above ^
Both my global installation (npm install -g jest-cli) and project (yarn add jest-cli) are on version v20.0.. I've added two lines here to compare:
https://github.com/facebook/jest/blob/master/packages/jest-cli/src/cli/runCLI.js#L108
console.log('projects', projects);
console.log('argv.projects', argv.projects);
In the global install that yields
projects [ '/home/eml/code/frontend' ]
argv.projects [ '/home/eml/code/frontend' ]
and in the local install
projects /home/eml/code/frontend
argv.projects undefined
The test in the line I linked to checks for projects.length > 1 which evaluates to true since the string has a few characters. I hope this can help debugging. Anything I can do?
@mull you need to run jest with extra -- when passing args through npm scripts (locally):
npm run test -- --projects myproject
@thymikee jest doesn't even seem to recognize --projects:
./node_modules/.bin/jest --projects myproject
Unrecognized options: projects
TypeError: projects.map is not a function
In any case I don't have multiple projects.
@mull this indicates that your Jest version isn't 20 and may have been installed wrong by npm. Remove node_modules and run (preferably) yarn or npm install once again
@thymikee sadly not :/
eml@eml-XPS-15-9560:~/code/frontend$ ./node_modules/.bin/jest --version
v20.0.4
eml@eml-XPS-15-9560:~/code/frontend$ ./node_modules/.bin/jest
TypeError: projects.map is not a function
at Object.<anonymous> (/home/eml/code/frontend/node_modules/jest-cli/build/cli/runCLI.js:112:28)
at next (native)
at step (/home/eml/code/frontend/node_modules/jest-cli/build/cli/runCLI.js:1:260)
at /home/eml/code/frontend/node_modules/jest-cli/build/cli/runCLI.js:1:490
at Object.<anonymous> (/home/eml/code/frontend/node_modules/jest-cli/build/cli/runCLI.js:1:171)
at Object.module.exports [as runCLI] (/home/eml/code/frontend/node_modules/jest-cli/build/cli/runCLI.js:139:50)
at Object.run (/home/eml/code/frontend/node_modules/jest/node_modules/jest-cli/build/cli/index.js:42:17)
at Object.<anonymous> (/home/eml/code/frontend/node_modules/jest/node_modules/jest-cli/bin/jest.js:16:25)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
Ok, so could you please setup a clean repo with this error?
@thymikee no actually.. I looked at my yarn.lock which reported version 18! yarn upgrade jest fixed it. I believe I had perhaps run yarn upgrade jest-cli before! Thanks for pointing me in the right direction :)
@kendaleiv please reinstall Jest just like @mull did. Closing.
I have the same problem and I solved in the same way than @tylercrosse. Installing via npm instead yarn. I think yarn is downloading some dependency in wrong version but I didn't discovered what.
I tried to clean yarn cache and delete yarn.lock and it didn't solve.
I tried it with node v6.11.0 and v8.1.3. In both the same problem.
Worked out for me after doing yarn upgrade ject-cli and yarn upgrade jest and the running npm install -D jest jest-cli.
Yarn is v0.27.5
Node is v6.10.2
Npm is v3.10.10
Most helpful comment
@thymikee no actually.. I looked at my
yarn.lockwhich reported version 18!yarn upgrade jestfixed it. I believe I had perhaps runyarn upgrade jest-clibefore! Thanks for pointing me in the right direction :)