gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 02:31:44 25 4
gpt4 key购买 nike

我是第一次尝试 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 以反射(reflect)我的应用程序的位置: - "start": "node nodejs/app/animalTest/bin/www"以替换默认的 .bin/www

要初始化应用程序,只有当我位于命令提示符中的 AnimalTest 目录中时,我才必须键入 npm start

感谢那些发表评论的人。

关于node.js - 当我输入 NPM start 时,Node/express 找不到我的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26086578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com