【问题标题】:Issue in starting Node App on Windows 7在 Windows 7 上启动 Node 应用程序的问题
【发布时间】:2015-02-03 19:59:27
【问题描述】:

我使用的是 Windows 7,并且我已经安装了 node.js 和 express。 在我使用下面的命令使用 express 创建项目后

> express projectName

创建了一个新项目,然后安装依赖项

> npm install 

到目前为止一切正常。但是当我尝试启动应用程序时

> npm start    

以下是我在 npm-debug.log 文件中遇到的问题。请建议这里有什么问题。 我尝试了许多其他线程,但找到的解决方案对我有用。

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@1.4.28
3 info using node@v0.10.33
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart NodeTestApp@0.0.0
7 info start NodeTestApp@0.0.0
8 verbose unsafe-perm in lifecycle true
9 info NodeTestApp@0.0.0 Failed to exec start script
10 error NodeTestApp@0.0.0 start: `node ./bin/www`
10 error spawn ENOENT
11 error Failed at the NodeTestApp@0.0.0 start script.
11 error This is most likely a problem with the NodeTestApp package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error     node ./bin/www
11 error You can get their info via:
11 error     npm owner ls NodeTestApp
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd C:\Users\Ali\Desktop\NodeTestApp
15 error node -v v0.10.33
16 error npm -v 1.4.28
17 error syscall spawn
18 error code ELIFECYCLE
19 error errno ENOENT
20 verbose exit [ 1, true ]

【问题讨论】:

  • 快速生成的应用程序应该调用./bin/www 而不是app.js。您是否在 package.json 中更改了此设置?如果您觉得您可能会忽略信息或跳过您采取的步骤。
  • @MatthewBakaitis 是的 ./bin/www 。我将其更改为 app.js,因为我正在学习教程。最初是 ./bin/www ,我更新了上面的结果 > npm start 。看起来几乎一模一样。

标签: windows node.js express npm


【解决方案1】:

child_process.spawn() 在找不到请求的可执行文件时返回ENOENT;在这种情况下,node.exe。仔细查看日志,我们可以看到npm start 正在尝试运行node app.js

你的PATH上有节点吗?如果你只是在命令行输入node app.js会发生什么?

【讨论】:

  • 当我只输入 node app.js 它什么也不做,控制又回到了同一个地方。结果低于 C:\Users\Ali\Desktop\airline2>node app.js
    C:\Users\Ali\Desktop\airline2>
  • 是的 node.js 在我的 PATH 变量中
【解决方案2】:

试试这个。它在 Windows 7 32 位 node.js 上为我工作

为您的项目创建新的空白文件夹。转到您的项目文件夹并手动创建 npm 文件夹(不要使用命令行)。

然后再次尝试创建新项目。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多