我的 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/