【问题标题】:How to resolve sh: react-scripts: command not found?如何解决 sh: react-scripts: command not found?
【发布时间】:2018-05-30 06:48:58
【问题描述】:

我使用 create-react-app 来生成一个应用程序。

create-react-app myapp

当我运行 yarn start 或 npm start 时出现此错误:

react-scripts 开始

sh: react-scripts: command not found npm ERR!文件 sh npm 错误!代码 生命周期 npm 错误! errno ENOENT npm 错误!系统调用产生 npm 错误! myapp@0.1.0 开始:react-scripts start npm 错误!生成 ENOENT npm 呃! npm 错误!在 myapp@0.1.0 启动脚本中失败。 npm 错误!这 可能不是 npm 的问题。可能有额外的日志记录 上面的输出。

当我运行 npm ls react:

myapp@0.1.0 /Users/johnno/foosball 
└── react@16.2.0

存在反应脚本。

这是我的 package.json:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-redux": "^5.0.6",
    "react-router": "^4.2.0",
    "react-scripts": "1.0.17",
    "redux": "^3.7.2",
    "yarn": "^1.3.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

我尝试了this 的建议,但无济于事。我该如何解决这个问题?

【问题讨论】:

  • 我们能看到你运行的所有命令吗?
  • 见上文更新问题
  • 您使用的是哪个版本的节点?你试过sudo npm start吗?
  • 节点版本 5.0.3
  • sudo npm start 没有区别

标签: macos reactjs create-react-app yarnpkg


【解决方案1】:

我通过删除解决了这个问题

节点模块
纱线锁
manifest_lock.json

并由

安装包
npm install

yarn

【讨论】:

  • 是的,谢谢,这对我也有用。作为概括,我希望应该删除所有“锁定”文件。 (当然,运行npm install 来重新生成node_modules/。)
  • 我试图在一个基于网络的项目中解决这个问题,'yarn' 对我有用。谢谢。
【解决方案2】:

以下步骤对我有用

  1. 删除node_modules文件夹
  2. 如果您正在使用yarn 命令,请删除yarn.lock;如果您正在使用npm 命令,请删除package-lock.json
  3. 运行yarn install(用于yarn 命令)或npm install(用于npm 命令)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-04
    • 2020-09-26
    • 2016-02-24
    • 2011-12-18
    • 1970-01-01
    • 2017-01-29
    • 1970-01-01
    • 2022-06-23
    相关资源
    最近更新 更多