由create-react-app创建后立即添加软件包不起作用 [英] Adding a package immediately after created by create-react-app is not working

查看:52
本文介绍了由create-react-app创建后立即添加软件包不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个非常新的反应者(从一天前开始).我使用create-react-app命令行创建了一个应用程序.我按以下顺序尝试了

I am very new to react (started a day ago). I used the create-react-app command line to create an app. I tried in the following order

  • create-react-app my-app
  • npm开始

此时,该应用程序运行正常.然后我做了以下

At this point the app is running fine. Then I did the following

  • npm安装youtube-api-search
  • npm开始

现在我遇到此错误

my-app@0.1.0开始/用户/shanmugharajk/代码/udemy/my-app反应脚本开始

my-app@0.1.0 start /Users/shanmugharajk/Code/udemy/my-app react-scripts start

sh:react-scripts:找不到命令npm ERR!文件sh npm ERR!代码ELIFECYCLE npm ERR!errno ENOENT npm ERR!syscall生成npm ERR!my-app@0.1.0开始:反应脚本开始 npm ERR!产生ENOENT npm呃!npm ERR!在my-app@0.1.0启动脚本处失败.npm ERR!这npm可能不是问题.可能还有其他日志记录上面的输出.

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.

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

This happens every single time with any package I try to install.

我想到的是我跑步的时候

One think I noted is when i run

  • npm install youtube-api-search或任何打包程序都会删除某些软件包.我在安装任何软件包时收到的消息是

npm WARN注册表使用来自 https://registry.npmjs.org/的陈旧数据因为主机无法访问-您是否处于离线状态?npm WARN注册表 https://registry.npmjs.org/的意外警告:其他警告ENOTFOUND:请求 https://registry.npmjs.org/redux 失败,原因:getaddrinfo ENOTFOUND Registry.npmjs.orgRegistry.npmjs.org:443 npm WARN注册表使用来自以下版本的过时软件包数据 https://registry.npmjs.org/由于在执行期间出现请求错误重新验证.npm轻轻警告Rm不移除/Users/shanmugharajk/Code/udemy/my-app/node_modules/html-minifier/node_modules/.bin/uglifyjs因为它不是由安装的/用户/shanmugharajk/代码/udemy/my-app/node_modules/html-minifier/node_modules/uglify-jsnpm轻轻警告Rm不移除/用户/shanmugharajk/代码/udemy/my-app/node_modules/espree/node_modules/.bin/acorn因为它不是由安装的/用户/shanmugharajk/代码/udemy/my-app/node_modules/espree/node_modules/acornnpm轻轻警告Rm不移除/用户/shanmugharajk/代码/udemy/my-app/node_modules/autoprefixer/node_modules/.bin/browserslist因为它不是由安装的/用户/shanmugharajk/代码/udemy/my-app/node_modules/autoprefixer/node_modules/浏览器列表npm通知创建了一个作为package-lock.json的锁文件.你应该犯该文件.

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添加了3个程序包,删除了1142个程序包,并在27.043s中更新了3个程序包

我不知道原因.请帮助我.

I couldn't figure out the reason. Please help me.

推荐答案

您正在使用npm5.目前,它有很多问题.

You are using npm 5. At the moment it has many issues.

我建议降级为npm 4,然后重试:

I recommend to downgrade to npm 4 and try again:

npm install -g npm@4

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

如果这没有帮助检查您的互联网连接.这似乎是您的网络存在的问题:

If it doesn't help check your internet connection. This looks like an issue with your network:

getaddrinfo ENOTFOUND注册表.npmjs.org注册表.npmjs.org:443

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

这篇关于由create-react-app创建后立即添加软件包不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆