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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token '.' #715

Closed
dep opened this issue May 19, 2022 · 4 comments
Closed

Unexpected token '.' #715

dep opened this issue May 19, 2022 · 4 comments
Labels

Comments

@dep
Copy link

dep commented May 19, 2022

Bug Description

This just started appearing today without warning in our CI builds. I'm not sure why, we haven't changed anything related to depcheck.

Code snippets

npx depcheck

Where the dependency is listed in package.json:

"devDependencies": {
  "@honeybadger-io/js": "3.2.7",
  "@storybook/preset-scss": "1.0.3",
  "@storybook/react": "6.4.22",
  "@storybook/storybook-deployer": "2.8.11",
  "backbone": "1.1.2",
  "bootstrap": "4.3.1",
  "chromatic": "6.5.4",
  "depcheck": "1.4.3",
  "formik": "^1.5.8",
  "graphql": "15.8.0",
  "graphql-tag": "2.12.6",
  "html-webpack-plugin": "5.5.0",
  "react": "17.0.2",
  "react-dom": "17.0.2",
  "reactstrap": "8.10.1",
  "sass-loader": "10.2.1",
  "storybook-addon-designs": "6.2.1"
}

Versions

  • node -v: v10.15.0
  • npm -v: 6.4.1
  • depcheck --version: 1.4.3

Extra info

n/a

@dep dep added the bug label May 19, 2022
@Alyshtar
Copy link

Alyshtar commented May 20, 2022

I have the same problem using depcheck with npx or trying to install it to use it localy.
Local invocation provides more details about the error :

C:\Users\Alyshtar\AppData\Roaming\npm\node_modules\depcheck\node_modules\@vue\compiler-sfc\dist\compiler-sfc.cjs.js:3316
                            s.prepend(`import { ${input.slice(specifier.local.start, specifier.local.end)} } from '${node.source?.value}'\n`);     
                                                                                                                                 ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\Alyshtar\AppData\Roaming\npm\node_modules\depcheck\dist\parser\vue.js:10:20)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

It seems to come from vue/compiler-sfc recent update.
Related issue here (I think).

@rumpl
Copy link
Member

rumpl commented May 20, 2022

Yeah, npx doesn't read the package lock, we would need to update the dependency and see what broke and how to fix it.

I opened a PR months ago, still have to merge it: #696

Anyone up for fixing this and opening a PR?

@dep
Copy link
Author

dep commented May 23, 2022

Started working again mysteriously today! Gonna be a good week. 🎉

@dep dep closed this as completed May 23, 2022
@busticated
Copy link

just hit this (i think). the error appears to be due to usage of optional chaining in Node.js versions less than v14 - see MDN Compatibility Chart

the error i see is:

            this.signal.onabort?.(reason);
                                ^

SyntaxError: Unexpected token '.'
Error Details

/Users/me/.fnm/node-versions/v12.22.12/installation/lib/node_modules/depcheck/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:361
            this.signal.onabort?.(reason);
                                ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/me/.fnm/node-versions/v12.22.12/installation/lib/node_modules/depcheck/dist/parser/vue.js:8:20)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

the fix (obv) is to use node@14 or greater 🤗

couldn't hurt to update the docs

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

No branches or pull requests

4 participants