使用 Ubuntu 13.10
我正在尝试使用 yeoman 安装,sudo npm install -g yo但它似乎不能在全局范围内工作npm并且nodejs已安装,但是,我不确定它们是否已正确安装以供全局使用。我不能使用npm我必须使用sudo npm
安装我使用的节点js
$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)
当我使用sudo npm install -g yo输出时,我得到的是
/usr/bin/yo -> /usr/lib/node_modules/yo/cli.js
> yo@1.2.1 postinstall /usr/lib/node_modules/yo
> node ./scripts/doctor
[Yeoman Doctor] Everything looks alright!
yo@1.2.1 /usr/lib/node_modules/yo
??? is-root@0.1.0
??? fullname@0.1.1
??? opn@0.1.2
??? async@0.9.0
??? shelljs@0.3.0
??? lodash@2.4.1
??? multiline@0.3.4 (strip-indent@0.1.3)
??? sudo-block@0.4.0 …Run Code Online (Sandbox Code Playgroud) 我有端口号是的 nodejs 应用程序,3001这个应用程序使用 http 但不适用于 https。在Apache服务器,用于设置翻领代理80或443到5001和一套翻领代理的3001也。
http://<domain>:3001/socket.io/socket.js ---> Work
https://<domain>:3001/socket.io/socket.js ---> Not Work(Secure Connection Failed or This site can’t be reached)
Run Code Online (Sandbox Code Playgroud)
在这里,我需要知道相同的端口(3001)与http和一起使用https?
有什么解决办法吗?
我正在尝试在 Ubuntu 18 上安装 node.js 12 并按照说明进行操作,当我输入
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
Run Code Online (Sandbox Code Playgroud)
我得到了下一个文本:
Reading package lists... Done
E: The repository 'http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.4 Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.0 Release' does not have a Release file.
N: Updating from such a repository can't be done …Run Code Online (Sandbox Code Playgroud) 当我跑步时,nvm alias default 12.8.0我得到了这个:
默认 -> 12.8.0 (-> v12.8.0)
但是,当我跑node -v,我得到v11.9.0代替
为什么会这样?
问题很简单,解决方法应该很简单。有关我的问题的更多详细信息。检查npm:
~ npm -version
>> 4.0.5
~ which npm
>> /usr/local/bin/npm
Run Code Online (Sandbox Code Playgroud)
尝试卸载:
~ sudo apt-get remove npm
>> Package 'npm' is not installed, so not removed
Run Code Online (Sandbox Code Playgroud)
好的,让我们安装它,而不是安装它:
~ sudo apt-get install npm
npm: Depends: nodejs but it will not be installed
Depends: node-abbrev (> = 1.0.4) but it is not installed
Depends: node-ansi but it will not be installed
Depends: node-archy but it will not be installed
Depends: node-block-stream but it will not be installed
Depends: node-fstream (> …Run Code Online (Sandbox Code Playgroud) 我尝试按照此答案方向安装 n 以进行节点版本更新。它成功地将我升级到节点 v7,但有一个副作用。现在已找到节点:
/usr/local/bin/node
Run Code Online (Sandbox Code Playgroud)
如果我输入,node -v我会收到 bash 错误,因为它在错误的位置查找(它在 中查找usr/bin/node)。我最好的前进道路是什么?如何更改终端查找节点的路径,以便我可以运行node index.js,同时不干扰我将来使用 n 升级节点的愿望。
我不确定这是否相关,但是,当我在一个项目中并且我输入的nodemon index.js一切都按预期工作。我认为这是因为nodemon安装在安装node v7的地方。
这是 的值echo $PATH:
/usr/local/heroku/bin:/home/devin/.rbenv/shims:/home/devin/.rbenv/bin:/usr/bin:/home/devin/bin:/home/devin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Run Code Online (Sandbox Code Playgroud)
这是 的值which node:
/usr/local/bin/node
Run Code Online (Sandbox Code Playgroud)
的值locate node使终端过载并结束如下:
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/node.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/outer_join.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/over.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/regexp.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/right_outer_join.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/select_core.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/select_statement.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/sql_literal.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/string_join.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/table_alias.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/terminal.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/true.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/unary.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/unary_operation.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/unqualified_column.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/update_statement.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/values.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/window.rb
/var/lib/gems/2.3.0/gems/arel-7.1.2/lib/arel/nodes/with.rb
/var/lib/gems/2.3.0/gems/execjs-2.7.0/lib/execjs/support/node_runner.js
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node.c
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node.h
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node.o
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node_set.c
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node_set.h
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/xml_node_set.o
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/css/node.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node_set.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/node/save_options.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/lib/nokogiri/xml/pp/node.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/html/test_node.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/html/test_node_encoding.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/node
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_attributes.rb
/var/lib/gems/2.3.0/gems/nokogiri-1.6.8/test/xml/test_node_encoding.rb …Run Code Online (Sandbox Code Playgroud) $ sudo apt-get install nvm\n\xe2\x80\xa6\nE: Unable to locate package nvm\nRun Code Online (Sandbox Code Playgroud)\n\n安装说明通常涉及运行来自 GitHub ( curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash) 的随机脚本,而不是使用众所周知的脚本apt-get或yum其他发行版的等效脚本。
为什么 nvm 没有为 Ubuntu 打包?
\n\n我想肯定有技术原因,因为 nvm 是一个常见的软件,比如许可问题或类似的问题,所以我很好奇为什么它无法打包。我在网上搜索了一个包和一个原因,但没有得到任何有用的结果。
\n我需要运行 nodejs v10.14。我目前运行的是 8.16.0 版。我找到了一些我遵循的说明,但它会导致错误(见下文)。
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
This causes the following output:
## Installing the NodeSource Node.js 10.x repo...
## Populating apt-get cache...
+ apt-get update
Hit:29 http://ppa.launchpad.net/wireshark-dev/stable/ubuntu bionic InRelease
Err:31 http://ppa.launchpad.net/ehoover/compholio/ubuntu bionic Release
404 Not Found [IP: 91.189.95.83 80]
Err:32 http://ppa.launchpad.net/pipelight/stable/ubuntu bionic Release
404 Not Found [IP: 91.189.95.83 80]
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ehoover/compholio/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be …Run Code Online (Sandbox Code Playgroud) 我使用的是 Ubuntu 20.04,我从 snap 商店安装了节点。现在,当我尝试安装 Angular cli 时,它不允许我这样做
2020/03/28 11:51:57.975509 cmd_run.go:884: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/2622": mkdir /nonexistent: permission denied
cannot create user data directory: /nonexistent/snap/node/2622: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @angular/cli@9.1.0 postinstall: `node ./bin/postinstall/script.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @angular/cli@9.1.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! …Run Code Online (Sandbox Code Playgroud) 我正在使用 Ionic,但我的构建失败了。它说我需要有最新的 npm 和 node.js。可悲的是,到目前为止,我在另一个主题等sudo apt-get update方面的尝试sudo apt-get upgrade未能移动14.17.3 LTS该网站所说的t 版本latest LTS。
https://nodejs.org/en/download/
我有很多设置,也不想破坏其他设置。如果有人可以提供正确的命令来更新到latest npm and nodejs LTS.
我经历过的主题有针对特定版本的命令并且很旧。谢谢。
更新1:
我从 Snap 商店安装了 nodejs 14。但不知道现在在哪里。当我使用 nodejs --version 时,它显示 v10。