gpt4 book ai didi

javascript - React 无法编译 postcss、yamldumper.js

转载 作者:太空宇宙 更新时间:2023-11-04 01:39:30 24 4
gpt4 key购买 nike

在 Windows 上当尝试从“create-react-app”编译新制作的 React 应用程序时,我收到编译错误。不确定意外的 token 来自哪里。该错误是指在创建 create-react-app 时,index.css 中出现意外的标记。

索引.css:

body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

安装和运行的输出如下:

D:\Projects\reactsites>cd Test2

D:\Projects\reactsites\Test2>npx create-react-app derpsocial

Creating a new React app in D:\Projects\reactsites\Test2\derpsocial.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[-----------------------------------------------------------------------] 0/1283(
node:3584) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.12.
3", while you're on "1.9.4".
info To upgrade, download the latest installer at "https://yarnpkg.com/latest.msi".
success Saved 6 new dependencies.
info Direct dependencies
├─ react-dom@16.6.3
├─ react-scripts@2.1.1
└─ react@16.6.3
info All dependencies
├─ babel-preset-react-app@6.1.0
├─ react-dev-utils@6.1.1
├─ react-dom@16.6.3
├─ react-error-overlay@5.1.0
├─ react-scripts@2.1.1
└─ react@16.6.3
Done in 236.47s.

Initialized a git repository.

Success! Created derpsocial at D:\Projects\reactsites\Test2\derpsocial
Inside that directory, you can run several commands:

yarn start
Starts the development server.

yarn build
Bundles the app into static files for production.

yarn test
Starts the test runner.

yarn eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can't go back!

We suggest that you begin by typing:

cd derpsocial
yarn start

Happy hacking!

D:\Projects\reactsites\Test2>cd derpsocial

D:\Projects\reactsites\Test2\derpsocial>yarn start
yarn run v1.9.4
$ react-scripts start
Failed to compile.

./src/index.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
D:\Projects\reactsites\Test2\derpsocial\node_modules\js-yaml\lib\js-yaml\dumper.js:275
return result;
^^^^^^

SyntaxError: Unexpected token return

D:\Projects\reactsites\Test2\derpsocial>npm -version
6.4.1

D:\Projects\reactsites\Test2\derpsocial>node -v
v10.13.0

D:\Projects\reactsites\Test2\derpsocial>

我尝试更新所有包,甚至从index.css中取出css,但出现相同的错误。重新安装了 Node 和 npm。

最佳答案

错误:“您当前的 Yarn 版本已过时”,然后:

npm install --global yarn

yarn ——版本0.21.3

来源:https://github.com/yarnpkg/yarn/issues/3042

关于javascript - React 无法编译 postcss、yamldumper.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53380645/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com