Mik*_*e K 2 reactjs create-react-app
我正在运行npm uninstall create-react-app,它返回
npm WARN saveError ENOENT: no such file or directory, open '/Users/me/Documents/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/me/Documents/package.json'
npm WARN Documents No description
npm WARN Documents No repository field.
npm WARN Documents No README data
npm WARN Documents No license field.
Run Code Online (Sandbox Code Playgroud)
我想更新我的 create-react-app 版本,显然他们不再支持全局安装。当我第一次(不久前)安装 CRA 时,它是全局安装的。现在,我正在尝试更新它,但遇到了问题。我跑了npm update create-react-app,但是我的终端只闪烁一秒钟并返回到提示。因此,我决定create-react-app完全卸载并重新安装它,但是现在我遇到了上述警告/问题。
对可能发生的事情有什么想法吗?
编辑:
当我运行时npm i create-react-app,它也会抛出上面的WARNs,但它也说
+ create-react-app@3.3.0 // <---
added 1 package and audited 578 packages in 1.787s
Run Code Online (Sandbox Code Playgroud)
但是,当我create-react-app --version再次运行命令时,它说3.2.0
编辑2:
我跑npm i -g create-react-app了几次,但抛出:
Michaels-MacBook-Pro:Documents me$ npm i -g create-react-app
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/create-react-app/index.js
npm ERR! dest /usr/local/bin/create-react-app
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'
npm ERR! File exists: /usr/local/bin/create-react-app
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2019-12-23T08_07_29_158Z-debug.log
Run Code Online (Sandbox Code Playgroud)
The*_*nol 109
全局卸载后create-react-app,我仍然收到错误消息,指出我的版本create-react-app已过时。这就是为我解决这个问题的方法:
后
sudo npm uninstall -g create-react-app
Run Code Online (Sandbox Code Playgroud)
跑步
npx clear-npx-cache
Run Code Online (Sandbox Code Playgroud)
然后尝试create-react-app在正确的工作目录中重新安装:
npx create-react-app my-app
Run Code Online (Sandbox Code Playgroud)
Ash*_*hok 13
要完全卸载它,请尝试运行
sudo npm uninstall -g create-react-app
Run Code Online (Sandbox Code Playgroud)
有时此命令可能无法完全删除包。如果是这样,只需检查其所在的目录
which create-react-app
Run Code Online (Sandbox Code Playgroud)
它会给你一些目录,比如/usr/local/bin/create-react-app。只需手动删除它
rm -rf /usr/local/bin/create-react-app
Run Code Online (Sandbox Code Playgroud)
现在您可以通过以下方式安装 create-react-app
npm install -g create-react-app
Run Code Online (Sandbox Code Playgroud)
但是,不建议从 v3.3.0 全局安装它。所以只需使用
npx create-react-app <project_name>
Run Code Online (Sandbox Code Playgroud)
只需重新运行此命令即可安装它。
sudo npm i -g create-react-app
我个人使用 NCU ( https://www.npmjs.com/package/npm-check-updates ) 来更新我的所有节点内容。它适用于全球和每个项目。
| 归档时间: |
|
| 查看次数: |
10280 次 |
| 最近记录: |