简体   繁体   English

npm 运行开发人员在全新安装时失败

[英]npm run devs fails on a clean install

I'm following a course and when I run npm run dev on the code I just downloaded (and that works in the video) I get this error.我正在学习一门课程,当我在刚刚下载的代码上运行 npm 运行 dev 时(并且在视频中有效),我收到了这个错误。 I've reinstalled node and npm, deleted node_modules folder and packale-lock.json and ran npm install again, doesnt work.我重新安装了 node 和 npm,删除了 node_modules 文件夹和 packale-lock.json 并运行 npm 再次安装,不起作用。

Here's the output这是 output

$ npm run dev

> twittor-server-client@1.0.0 dev C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting
> ./node_modules/nodemon/bin/nodemon.js server/server

"." no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! twittor-server-client@1.0.0 dev: `./node_modules/nodemon/bin/nodemon.js server/server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the twittor-server-client@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrador\AppData\Roaming\npm-cache\_logs\2020-04-12T18_53_06_036Z-debug.log 

Here's the debug log:这是调试日志:

0 info it worked if it ends with ok
1 verbose cli [
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   'run',
1 verbose cli   'dev'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.16.2
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle twittor-server-client@1.0.0~predev: twittor-server-client@1.0.0
6 info lifecycle twittor-server-client@1.0.0~dev: twittor-server-client@1.0.0
7 verbose lifecycle twittor-server-client@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle twittor-server-client@1.0.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Administrador\bin;C:\Program Files\Microsoft MPI\Bin;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Crucial\Crucial Storage Executive;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Java\jdk1.8.0_201\bin;C:\apache-ant-1.10.7\bin;C:\Users\ Usuario\IdeaProjects\mysql-connector-java-5.1.48;C:\ProgramData\chocolatey\bin;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\MinGW\bin;C:\Program Files\nodejs;C:\Users\Administrador\AppData\Roaming\local\bin;C:\Users\Administrador\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrador\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Administrador\AppData\Roaming\npm
9 verbose lifecycle twittor-server-client@1.0.0~dev: CWD: C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting
10 silly lifecycle twittor-server-client@1.0.0~dev: Args: [ '/d /s /c', './node_modules/nodemon/bin/nodemon.js server/server' ]
11 silly lifecycle twittor-server-client@1.0.0~dev: Returned: code: 1  signal: null
12 info lifecycle twittor-server-client@1.0.0~dev: Failed to exec dev script
13 verbose stack Error: twittor-server-client@1.0.0 dev: `./node_modules/nodemon/bin/nodemon.js server/server`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:310:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:310:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid twittor-server-client@1.0.0
15 verbose cwd C:\Users\Administrador\Desktop\PWA\10-twittor-offline-posting
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v12.16.2
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error twittor-server-client@1.0.0 dev: `./node_modules/nodemon/bin/nodemon.js server/server`
22 error Exit status 1
23 error Failed at the twittor-server-client@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

And the package.json: package.json:

{
    "name": "twittor-server-client",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node server/server.js",
        "dev": "./node_modules/nodemon/bin/nodemon.js server/server"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
        "express": "^4.16.3"
    },
    "devDependencies": {
        "nodemon": "^1.18.4",
        "webpack-dev-server": "^3.10.3"
    }
}

Says in the output that the "."在 output 中说“。” in front of the dev script path is not recognized but this is all auto-generated...前面的开发脚本路径无法识别,但这都是自动生成的......

I guess, npm cache clean && rm -rf node_modules && npm i should work.我想,npm 缓存清理 && rm -rf node_modules && npm 我应该可以工作。 But since you already have nodemon in your dev dependencies.但是由于您的开发依赖项中已经有 nodemon 。 Try replacing the dev script with "nodemon server/server.js" – Rahul Sharma Apr 12 at 19:28I guess, npm cache clean && rm -rf node_modules && npm i should work.尝试用“nodemon server/server.js”替换开发脚本——Rahul Sharma 4 月 12 日 19:28 我猜,npm cache clean && rm -rf node_modules && npm 我应该可以工作。 But since you already have nodemon in your dev dependencies.但是由于您的开发依赖项中已经有 nodemon 。 Try replacing the dev script with "nodemon server/server.js" – Rahul Sharma Apr 12 at 19:28尝试用“nodemon server/server.js”替换开发脚本——Rahul Sharma 4 月 12 日 19:28

This command worked for me:这个命令对我有用:

{
"name": "twittor-server-client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server/server.js",
    "dev": "nodemon server/server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
    "body-parser": "^1.18.3",
    "express": "^4.16.3"
},
"devDependencies": {
    "nodemon": "^1.18.4"
}

} }

Hope it can help you @Julian希望它可以帮助你@Julian

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM