question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError Unexpected token, expected "{"

See original GitHub issue

你好,我使用typescript,想用father打包,结果一直报错: 报错如下: image

版本:“father”: “^2.24.0”, .fatherrc.js配置如下

export default {
  entry: 'src/index.js',
  esm: 'rollup',
  cjs: 'rollup',
};

tsconfig.json配置:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "jsx": "react",
    "esModuleInterop": true,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
xileliucommented, Nov 14, 2019

@dkvirus 嗯是不报错了也可以正常build成功.

tsconfig.json 增加 “skipLibCheck”: true,配置应该不需要yarn add @types/vfile-message

1reaction
dkviruscommented, Nov 11, 2019

@sorrycc 逗号去掉,打包只会生成目录,不会生成打包文件,终端仍会报错:

/temp/umi-ts-demo/node_modules/@types/vfile/index.d.ts(11,31): error TS7016: Could not find a declaration file for module 
'vfile-message'. '/temp/umi-ts-demo/node_modules/vfile-message/index.js' implicitly has an 'any' type.
  Try `npm install @types/vfile-message` if it exists or add a new declaration (.d.ts) file containing `declare module 'vfile-message';`

报错信息字面意思 @types/vfile-message 这个包有问题,我尝试了它建议的两种方式,打包仍旧失败。

  • yarn add @types/vfile-message
  • declare module 'vfile-message';

最终发现脚手架里的 @types/vfile-message 版本是 1.0.1,而 淘宝镜像网 查询 @types/vfile-message 该包已废弃,vfile-message 包自身提供类型声明,最终我手动安装 vfile-message 最新版本(2.0.2),打包成功。

Stub TypeScript definitions entry for vfile-message, which provides its own types definitions

在 yarn.lock 找到依赖关系,顶层是 @umijs/fabric > eslint-plugin-markdown > unified > vfile > vfile-message。希望能从源头(@umijs/fabric)升级依赖包版本以解决该问题。

Read more comments on GitHub >

github_iconTop Results From Across the Web

React — Syntax error: Unexpected token, expected
Well, you are getting error because you are defining the function like in a class, not in a function. Use a proper function...
Read more >
Have a JavaScript Unexpected Token Error? Check Your Syntax
The JavaScript's parser expects tokens and symbols in a particular order, with relevant values or variables in between. Often, an Unexpected ...
Read more >
Syntax Error: Unexpected token, expected "," (1:22) - MongoDB
Hi guys, I'm pretty new to MongoDB and just starting my journey learning different ways I can query my documents.
Read more >
(syntax error) unexpected token, expected "}" - Replit
I believe this to be a syntax error, but I fail to find where it is. On line 49, there is said to...
Read more >
React Native: Unexpected token ':'. Expected a ')' or a ',' after a ...
App shows red box with the error: SyntaxError: Unexpected token ':'. Expected a ')' or a ',' after a parameter declaration. No Stack ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found