Rnj*_*Rnj 20 ubuntu node.js npm reactjs
我试图创建一个反应应用程序,但得到了关注
$ npx create-react-app react-demo
npx: installed 67 in 6.045s
You are running Node 10.19.0.
Create React App requires Node 14 or higher.
Please update your version of Node.
Run Code Online (Sandbox Code Playgroud)
在解决方案中,此答案要求运行npm i -g npm@latest,这会产生另一个错误:
$ sudo npm i -g npm@latest
npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
#unloaded = false
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:22:15)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
Run Code Online (Sandbox Code Playgroud)
此错误的解决方案要求卸载,npm但会出现相同的错误:
$ sudo npm uninstall -g npm
npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
#unloaded = false
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
//..
at Module._compile (internal/modules/cjs/loader.js:778:30)
Run Code Online (Sandbox Code Playgroud)
上述错误的解决方案要求安装帮助程序实用程序n,这也会给出相同的错误:
$ sudo npm install -g n
npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
#unloaded = false
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
//..
at Module._compile (internal/modules/cjs/loader.js:778:30)
Run Code Online (Sandbox Code Playgroud)
我对这里发生的事情感到非常困惑。我该如何解决?
PS:我对 npm 和 node 还很陌生。
Sak*_*jan 32
这对我有用
npm cache clean -f
sudo npm install -g n
sudo n latest
Run Code Online (Sandbox Code Playgroud)
小智 7
我的解决方案是使用更新ubuntu$ sudo apt update
然后使用$ sudo n stable 安装最新版本的nodejs
您需要的是节点管理器,npm install -g n在使用之前安装$ sudo n stable
| 归档时间: |
|
| 查看次数: |
74675 次 |
| 最近记录: |