【问题标题】:error TS6046: Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'错误 TS6046:“--jsx”选项的参数必须是:“preserve”、“react-native”、“react”
【发布时间】:2021-07-14 22:42:28
【问题描述】:

在我的 PC 上,我无法编译在另一台 PC 上流畅运行的 ReactJs 项目。

我不明白问题出在哪里。

react-scripts start

error TS6046: Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @coreui/coreui-free-react-admin-template@2.6.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @coreui/coreui-free-react-admin-template@2.6.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Marco\AppData\Roaming\npm-cache\_logs\2021-04-20T17_20_33_546Z-debug.log

该文件包含以下内容:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.9
3 info using node@v14.15.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @coreui/coreui-free-react-admin-template@2.6.0~prestart: @coreui/coreui-free-react-admin-template@2.6.0
6 info lifecycle @coreui/coreui-free-react-admin-template@2.6.0~start: @coreui/coreui-free-react-admin-template@2.6.0
7 verbose lifecycle @coreui/coreui-free-react-admin-template@2.6.0~start: unsafe-perm in lifecycle true
10 silly lifecycle @coreui/coreui-free-react-admin-template@2.6.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle @coreui/coreui-free-react-admin-template@2.6.0~start: Returned: code: 1  signal: null
12 info lifecycle @coreui/coreui-free-react-admin-template@2.6.0~start: Failed to exec start script
13 verbose stack Error: @coreui/coreui-free-react-admin-template@2.6.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid @coreui/coreui-free-react-admin-template@2.6.0
15 verbose cwd E:\Projects\PrimaryX-FrontEnd
16 verbose Windows_NT 10.0.19041
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v14.15.3
19 verbose npm  v6.14.9
20 error code ELIFECYCLE
21 error errno 1
22 error @coreui/coreui-free-react-admin-template@2.6.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the @coreui/coreui-free-react-admin-template@2.6.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

任何线索如何以及如何解决?

【问题讨论】:

  • 你的项目有 tsconfig 吗?您是否安装了节点模块?
  • @SethLutske 两个问题都同意

标签: reactjs npm


【解决方案1】:

我相信您在旧项目中使用的是最新版本的 NODEJS。 你可以降级你的 nodejs 或者更新 webpack

【讨论】:

    猜你喜欢
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 2023-01-21
    • 2017-07-27
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 2022-01-05
    相关资源
    最近更新 更多