Node.js 当我键入NPM start时,Node/express找不到我的应用程序

Node.js 当我键入NPM start时,Node/express找不到我的应用程序,node.js,Node.js,我是第一次尝试node.js,但在开始时遇到了一些问题。我已经在w:/nodejs/app/animaltest/package.json安装了express。该应用程序名为“animalTest” { "name": "animalTest", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "dependencies": { "express"

我是第一次尝试node.js,但在开始时遇到了一些问题。我已经在w:/nodejs/app/animaltest/package.json安装了express。该应用程序名为“animalTest”

{
  "name": "animalTest",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "express": "~4.9.0",
    "body-parser": "~1.8.1",
    "cookie-parser": "~1.3.3",
    "morgan": "~1.3.0",
    "serve-favicon": "~2.1.3",
    "debug": "~2.0.0",
    "hjs": "~0.0.6",
    "less-middleware": "1.0.x"
  }
}
当我试图通过键入“npm start”启动应用程序时,我从命令提示符处收到以下错误。是否有错误的参考?例如,“不正常代码0”没有多大帮助

    0 info it worked if it ends with ok
1 verbose cli [ 'W:\\nodejs\\\\node.exe',
1 verbose cli   'W:\\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.32
4 verbose node symlink W:\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart animalTest@0.0.0
7 info start animalTest@0.0.0
8 verbose unsafe-perm in lifecycle true
9 info animalTest@0.0.0 Failed to exec start script
10 error animalTest@0.0.0 start: `node ./bin/www`
10 error Exit status 8
11 error Failed at the animalTest@0.0.0 start script.
11 error This is most likely a problem with the animalTest 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 animalTest
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "W:\\nodejs\\\\node.exe" "W:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd W:\nodejs\app\animalTest
15 error node -v v0.10.32
16 error npm -v 1.4.28
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]

我必须编辑package.json以反映我的应用程序的位置:-“start”:“node nodejs/app/animalTest/bin/www”以替换默认的.bin/www

要初始化应用程序,我必须在命令提示符下的animalTest目录中键入npm start


感谢那些发表评论的人

我通过编辑
bin\www
文件解决了这个问题。 此问题仅在Windows上出现,不适用于Mac或Linux

您只需删除crunchbang
#/usr/bin/env节点
位于第一行


我希望这能解决您的问题。

请出示您的package.json。此外,您确定express软件包位于node_模块文件夹中吗?是的,express位于my animalTest(应用程序名)目录中的node_模块文件夹中。那么,当您运行“node./bin/www”时,问题就发生了。试着直接在命令行中运行它,看看会发生什么。此外,如果
www
是一个JavaScript文件,则必须包含文件扩展名。如果手动在cmd提示符中找到www文件并键入“node www”,则我的express应用程序将正确加载,这非常好。如果它是这样工作的,那么如果“节点启动”不起作用,我需要麻烦吗?唯一的问题是,每次我想加载我的应用程序时,我都必须进入这个目录。也许只有在正确定义了工作目录后,你的程序才能正常运行。您是否尝试将开始脚本更改为
cd-bin;节点www;cd..