gpt4 book ai didi

reactjs - 创建 react 应用程序- react 脚本: command not found

转载 作者:行者123 更新时间:2023-12-03 14:12:03 26 4
gpt4 key购买 nike

我刚刚开始在 codepen 上使用 React,我真的很喜欢它!我决定将其安装在我的 MacBook Air 上。我使用 npm 安装了 create-react-app,一切看起来都很好。然后我开始了一个项目,一切都很顺利。当我运行 npm start 时,出现错误:

sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! react-app@0.1.0 start: 'react-scripts start'
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the react-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我得出的结论是 npm 找不到 react 脚本。我几乎已经完成了我能想到的所有事情:我更新了 npm;我已经重新安装了模块;我已经开始了一个新项目,但仍然遇到同样的错误。我检查过,react-scripts 位于我的 node_modules 文件中。我唯一没有做的就是全局安装react-scripts,但create-react-app的创建者说这是一个非常糟糕的主意。我该怎么办?

最佳答案

刚刚解决了问题:

package.json中,我将“start”:react-scripts start“更改为“start”:“NODE_ENV=生产node_modules/react- scripts/bin/react-scripts.js start"。这解决了问题。

关于reactjs - 创建 react 应用程序- react 脚本: command not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53460247/

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