node.js - “node server.js”工作,但“npm start”找不到节点
问题描述
在一个空目录中,我创建了一个文件'server.js',它所做的只是一个console.log('hello')。使用“node server.js”运行此文件运行良好。但是在通过“npm start”运行的“npm init -y”之后给出:
npm start
The system cannot find the path specified.
> prj@1.0.0 start E:\projects\prj
> node server.js
/bin/bash: node: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file bash
npm ERR! errno ENOENT
npm ERR! prj@1.0.0 start: `node server.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the prj@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
详细的日志文件报告 npm 和 node 的正确版本。所有这一切都是在卸载/重新安装 node.js 之后发生的。
任何有关如何排除故障/修复的提示表示赞赏。
项目目录:
E:\prj
package.json
package-lock.json
server.js
package.json 是 npm init 之后的默认值:
{
"name": "prj",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
解决方案
推荐阅读
- matlab - MATLAB 中的斐波那契函数
- java - 如何将二进制文件添加到 Azure Function 的 Java 包中
- algorithm - 有序 9 位问题的算法可能是什么?
- http - 发出发布请求时出现Vuejs axios错误
- arrays - 是否有用于模糊查找的 Google Apps 脚本?
- c - 学习 zybooks 中的嵌套循环
- java - 过滤数据库表时变量消失
- keycloak - 用于更新用户 API 的 Keycloak Admin Rest API unknown_error
- javascript - onChange 事件功能在我的 React 应用程序中滞后
- google-cloud-platform - 前端 IP 在 Google 云内部 HTTP(S) 负载平衡上侦听 HTTP 和 HTTPS,