Node.js 意外标记“.”

问题描述 投票:0回答:1

我是 Linux、js 和 node.js 开发的新手,如果这个问题很愚蠢,我很抱歉......但是。

我的本地测试服务器上有我的第一个应用程序。当我进入包含代码的文件夹并输入 npm start 时,一切正常。 但 我想在后台运行它并使用 systemctl 来使用该应用程序。但是当我使用 sudo systemctl start“我的应用程序”时,我得到了

请帮助我:/

意外的标记“.”

Stopping My Eclipse Application... eclipse.service: Deactivated successfully. Stopped My Eclipse Application. Started My Eclipse Application. [email protected] start nodemon server.js [nodemon] 3.1.0 [nodemon] to restart at any time, enter `r\>
\[nodemon\] watching path(s): *.*
\[nodemon\] watching extensions: js,mjs,cjs,\>
\[nodemon\] starting `node server.js`
/var/www/projects/eclipse/node_modules/mon\>
session: options?.session,
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/load\>
at Module.\_compile (internal/modules/c\>
at Object.Module.\_extensions..js (inte\>
at Module.load (internal/modules/cjs/l\>
at Function.Module.\_load (internal/mod\>
at Module.require (internal/modules/cj\>
at require (internal/modules/cjs/helpe\>
at Object.\<anonymous\> (/var/www/projec\>
at Module.\_compile (internal/modules/c\>
at Object.Module.\_extensions..js (inte\>
\[nodemon\] app crashed - waiting for file c\>\

.服务

[Unit]
Description=My Eclipse Application

[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/var/www/projects/eclipse
Restart=always

[Install]
WantedBy=multi-user.target

Node.js v20.12.2。 节点监控-v3.1.0 nvm-v0.39.7

我尝试过更新 nvm、nodemon、node.js。仅像从应用程序文件夹中启动 nvm 一样运行它。

javascript node.js linux express ubuntu
1个回答
0
投票

节点路径错误。

从 nvm 粘贴路径,哪个节点有帮助

© www.soinside.com 2019 - 2024. All rights reserved.