sindresorhus / find-up

Find a file or directory by walking up parent directories
MIT License
582 stars 40 forks source link

Error for an unexpected token while on code coverage #34

Closed corn-snake closed 5 years ago

corn-snake commented 5 years ago

When I try to execute a code coverage operation in CircleCI, the following error pops up:

/home/circleci/repo/node_modules/nyc/node_modules/find-up/index.js:5
module.exports = (filename, opts = {}) => {
                                 ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/circleci/repo/node_modules/nyc/lib/config-util.js:6:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
npm ERR! Test failed.  See above for more details.
Exited with code 1
sholladay commented 5 years ago

Would you please tell us the Node.js version you are using on Circle CI and version of find-up that is being used (look in node_modules/nyc/node_modules/find-up/package.json)?

I'm pretty sure you are using an old Node.js version, probably 4.x. Circle CI is bad at keeping their environments up to date. As you can see in engines, we only support 6.x and up. You should configure Circle CI to use a more modern version of Node by putting something like this in your .circleci/config.yml file:

jobs:
  build:
    docker:
      - image: circleci/node:8.9
corn-snake commented 5 years ago

This seemed to hit the right spot! Thank you very much.

Though I'm still surprised, because when using:

      - run:
          name: update_apt
          command: curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
      - run:
          name: update_node
          command: sudo apt-get install -y nodejs

to "update" the environment, it really doesn't truly do so, if the error was still being thrown

sholladay commented 5 years ago

Great, glad that worked.

I'm not quite sure why your other solution doesn't work. Maybe those commands are run concurrently.