macos - 由 create-react-app 创建后立即添加包不起作用

标签 macos reactjs npm create-react-app

我的 react 很新(一天前开始)。我使用 create-react-app 命令行来创建应用程序。我按照以下顺序尝试了

  • 创建 react 应用程序我的应用程序
  • npm 启动

此时应用程序运行良好。然后我做了以下事情

  • npm 安装 youtube-api-search
  • npm 启动

现在我收到此错误

my-app@0.1.0 start /Users/shanmugharajk/Code/udemy/my-app react-scripts 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! my-app@0.1.0 start: react-scripts start npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the my-app@0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我尝试安装的任何软件包每次都会发生这种情况。

我认为我注意到的一个是当我运行时

  • npm install youtube-api-search 或任何软件包,它总是会删除一些软件包。我在安装任何软件包时收到的消息是

npm WARN registry Using stale data from https://registry.npmjs.org/ because the host is inaccessible -- are you offline? npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning ENOTFOUND: request to https://registry.npmjs.org/redux failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation. npm WARN gentlyRm not removing /Users/shanmugharajk/Code/udemy/my-app/node_modules/html-minifier/node_modules/.bin/uglifyjs as it wasn't installed by /Users/shanmugharajk/Code/udemy/my-app/node_modules/html-minifier/node_modules/uglify-js npm WARN gentlyRm not removing /Users/shanmugharajk/Code/udemy/my-app/node_modules/espree/node_modules/.bin/acorn as it wasn't installed by /Users/shanmugharajk/Code/udemy/my-app/node_modules/espree/node_modules/acorn npm WARN gentlyRm not removing /Users/shanmugharajk/Code/udemy/my-app/node_modules/autoprefixer/node_modules/.bin/browserslist as it wasn't installed by /Users/shanmugharajk/Code/udemy/my-app/node_modules/autoprefixer/node_modules/browserslist npm notice created a lockfile as package-lock.json. You should commit this file.

  • redux@3.7.1 added 3 packages, removed 1142 packages and updated 3 packages in 27.043s

我无法找出原因。请帮助我。

最佳答案

您正在使用 npm 5。目前它有很多问题。

我建议降级到 npm 4 并重试:

npm install -g npm@4

rm -rf node_modules
rm package-lock.json
npm install

如果这没有帮助,请检查您的互联网连接。 这看起来像是您的网络问题:

getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

关于macos - 由 create-react-app 创建后立即添加包不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44860917/

相关文章:

reactjs - NextJS中的摇晃树包括所有的node_modules包,即使没有全部使用它

mysql - 远程连接到Mac OS X上的MySQL服务器-错误2003(HY000):无法连接到duplessis.umontreal.ca上的MySQL服务器(110)

cocoa - 以编程方式检查进程是否正在 Mac 上运行

reactjs - 如何在 native react 中淡出 View 的边缘?

laravel - 如何在blade模板中使用React js

javascript - 如何在 react 中单击按钮将一个组件移动到另一个组件?

node.js - Ansible 和 npm 安装失败并显示 "rc -9"。这是什么意思?

C 和 Nasm64 组合 - 堆栈对齐、尾声、序言 - OSX 64

php - Apache 2.4 不加载 php5.5 与 Mac OS 10.8

node.js - 将私有(private)存储库部署为依赖项