我遵循了这个要点https://gist.github.com/Goddard/5500157来安装 nodejs 和 npm,但是在运行它之后,node --version 或 npm --version 都无法运行,给出了找不到命令的错误。我能够卸载 nodejs,但必须进入脚本中描述的临时目录并执行 make uninstall 以使 npm 离开。
现在为了再次安装 nodejs 和 npm,我使用了这个链接http://www.andreagrandi.it/2013/02/08/how-to-install-latest-stable-node-js-on-ubuntu/,但是如果我尝试同时安装 nodejs 和 npm,我会收到此错误消息。
sudo apt-get install nodejs npm
The following packages have unmet dependencies:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)
如果我只安装运行良好的 nodejs。
sudo apt-get install nodejs
node --version
v0.10.15
Run Code Online (Sandbox Code Playgroud)
但是现在如果我尝试安装 npm 它会给我这个错误信息
sudo apt-get install npm
The following packages have unmet dependencies:
npm : Depends: nodejs (>= 0.6.19~dfsg1-3) but …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 centos 7 上安装 nodejs 和 npm
所以首先我做了 rpm -i http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm 来获取 epel 存储库
然后我尝试了 yum install nodejs。哪个有效。然后我尝试了 yum install npm。Yum 返回“未找到 npm 包”
我必须手动构建 npm 吗?我该怎么做?
我是 Node 的新手,但我一直在尝试安装一些 npm 模块,在看似成功安装之后,我无法运行新应用程序。我必须有一些基本的配置错误,比如我的 PATH 中缺少位置...
例如,运行:
npm install -g karma
Run Code Online (Sandbox Code Playgroud)
我得到:
npm http GET https://registry.npmjs.org/karma
npm http 304 https://registry.npmjs.org/karma
npm http GET https://registry.npmjs.org/glob
... (many, many GETs......)
> ws@0.4.25 install /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
/usr/local/share/npm/bin/karma -> /usr/local/share/npm/lib/node_modules/karma/bin/karma
> karma@0.8.3 install /usr/local/share/npm/lib/node_modules/karma
> node install-log4js.js
npm http GET https://registry.npmjs.org/log4js/0.6.2
npm http 304 https://registry.npmjs.org/log4js/0.6.2
npm http GET https://registry.npmjs.org/async/0.1.15
npm http GET …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为一个简单的 React 应用程序设置一个 systemd 服务。此应用程序托管在 /home/myuser/test 中。npm 和 node 都在 PATH 中并且硬链接到 /usr/bin。所有文件都具有 myuser:myuser 用户和组的权限。如果我手动启动它,npm start
它会正确启动并从http://localhost:3000
Compiled successfully!
You can now view test in the browser.
Local: http://localhost:3000
On Your Network: http://myipaddress:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
Run Code Online (Sandbox Code Playgroud)
如果我尝试通过 systemd 启动应用程序,它会失败但没有说明原因。我从相同的路径、相同的用户启动它,并尝试了 ExecStart 可以想象的所有组合:
ExecStart=npm start
ExecStart=/usr/bin/npm start
ExecStart=/usr/bin/node /home/myuser/test/node_modules/react-scripts/scripts/start.js
Run Code Online (Sandbox Code Playgroud)
它们都产生相同的结果,即它“开始”正常,但很快就失败了,在 journalctl 中显然没有理由:
$sudo systemctl status node-client
? node-client.service - Node-React Frontend Server
Loaded: loaded (/etc/systemd/system/node-client.service; disabled; …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 Debian 服务器上安装 Laravel,但在安装node-sass
. 我有这个设置很长时间了,以前从未遇到过问题。也许node-sass
或npm
最近改变了什么?
希望你能帮助我,我已经卡了 2 天了。
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.3.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! node-sass@3.8.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.8.0 install script 'node scripts/install.js'.
npm …
Run Code Online (Sandbox Code Playgroud) 环境: CentOS 8、Node.js、Digital Ocean Droplet
我的 Systemd 设置使用以下命令启动节点应用程序。它按预期工作。
$ sudo systemctl start myapp
Run Code Online (Sandbox Code Playgroud)
文件 1: /etc/systemd/system/myapp.service
[Unit]
Description = My App
After = network.target
[Service]
ExecStart = /root/start-myapp.sh
Restart=on-failure
[Install]
WantedBy = multi-user.target
Run Code Online (Sandbox Code Playgroud)
文件2: /root/start-myapp.sh
#!/bin/sh
/usr/bin/node /srv/myapp/app.js
Run Code Online (Sandbox Code Playgroud)
但是,当我不使用 Systemd 时,我通常会使用命令npm start
. 我宁愿让 Systemd 单元也用npm start
.
不幸的是扔了一个错误,当我换app.js
到npm start
的/root/start-myapp.sh
,
/usr/bin/node /srv/myapp/npm start
Run Code Online (Sandbox Code Playgroud)
我通过从切换路径作了一次尝试node
来npm
,但它产生的同样的错误。
/usr/bin/npm /srv/myapp/npm start
Run Code Online (Sandbox Code Playgroud)
问题:如何让我的 Systemd 单元文件使用命令启动我的应用程序npm start
?