我正在尝试使用以下命令安装下一个js:
$c:/Desktop/next: npm init next-app nextjs-blog
哪个给我一个错误
npm ERR! Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
Note:我的用户是C:/Users/Sunita Dahal
,但似乎在Dahal
内部。但是我能够安装全局软件包。reinstalling & cleaning cache doesnt work work me
这里是完整的错误日志:
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 'install',
1 verbose cli 'create-next-app@latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli 'C:\\Users\\Sunita',
1 verbose cli 'Dahal\\AppData\\Roaming\\npm-cache\\_npx\\14636',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session a7314bdab23f336e
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:Dahal\AppData\Roaming\npm-cache\_npx\14636 Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
8 http fetch GET 304 https://registry.npmjs.org/create-next-app 167ms (from cache)
9 silly pacote tag manifest for create-next-app@latest fetched in 190ms
10 timing stage:rollbackFailedOptional Completed in 1ms
11 timing stage:runTopLevelLifecycles Completed in 204ms
12 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\Sunita Dahal\Desktop\next\Dahal\AppData\Roaming\npm-cache\_npx\14636\package.json'
13 verbose cwd C:\Users\Sunita Dahal\Desktop\next
14 verbose Windows_NT 10.0.18362
15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-next-app@latest" "--global" "--prefix" "C:\\Users\\Sunita" "Dahal\\AppData\\Roaming\\npm-cache\\_npx\\14636" "--loglevel" "error" "--json"
16 verbose node v12.16.3
17 verbose npm v6.14.4
18 error code ENOLOCAL
19 error Could not install from "Dahal\AppData\Roaming\npm-cache\_npx\14636" as it does not contain a package.json file.
20 verbose exit [ 1, true ]
因此命令npm init
将初始化一个新项目,并生成一个包含项目相关信息的package.json
文件。该命令可以在任何地方运行。要创建自己的新项目时,请使用npm init
。
但是,npm install
或简称为npm i
,将在现有项目目录的package.json
文件中安装与项目相关的依赖项。您也可以使用npm i package_name_here
将新软件包安装到当前项目中。该命令必须在具有有效package.json