最近我遇到了一些关于基本npm命令的问题。
我有下面的package.json:
{
"name": "bundle",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"author": "",
"license": "ISC",
"scripts": {
"install": "npm i",
"bundle": "webpack",
"watch": "webpack --mode=development --watch"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"babel-loader": "^9.1.0",
"css-loader": "^6.7.1",
"html-webpack-plugin": "^5.5.0",
"sass": "^1.56.0",
"sass-loader": "^13.1.0",
"source-map-loader": "^4.0.1",
"style-loader": "^3.3.1",
"ts-loader": "^9.4.1",
"typescript": "^4.8.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
尝试安装时出现以下错误:
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
> bundle@1.0.0 install
> npm i
'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_56_965Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_56_990Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_57_010Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_35_57_032Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\Niklas\Desktop\Project\Learn4Fun\Web\wwwroot
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm i
其中一个日志文件。(这是从VS 2022运行时
0 verbose cli [
0 verbose cli 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs\\node.exe',
0 verbose cli 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\VisualStudio\\NodeJs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli 'prefix',
0 verbose cli '-g'
0 verbose cli ]
1 info using npm@8.3.1
2 info using node@v16.14.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:C:\Users\Niklas\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VisualStudio\NodeJs\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 6ms
18 timing npm:load:configload Completed in 6ms
19 timing npm:load:setTitle Completed in 0ms
20 timing config:load:flatten Completed in 2ms
21 timing npm:load:display Completed in 2ms
22 verbose logfile C:\Users\Niklas\AppData\Local\npm-cache\_logs\2022-11-19T21_17_05_361Z-debug-0.log
23 timing npm:load:logFile Completed in 4ms
24 timing npm:load:timers Completed in 0ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load Completed in 13ms
27 timing command:prefix Completed in 1ms
28 verbose exit 0
29 timing npm Completed in 171ms
30 info ok
我尝试过卸载/重新安装节点/npm(不同版本)。删除了npm缓存。删除了电脑上的所有npm文件夹。重新启动了电脑。
2条答案
按热度按时间6ju8rftf1#
是否将路径设置为npm?
在Windows环境变量中
uxhixvfz2#
删除所有内容。运行npm init并将完全相同的包引用复制到新的package.json中。