"npm install" 不适用于从 github 中提取的 React 项目

"npm install" not working for react project pulled from github

我正在使用 ubuntu 20.04.4 LTS。 我正在尝试在本地安装一个反应项目。

我尝试从 github 克隆 de repo,并在本地安装 React 应用程序,这样做:

git clone https://github.com/OpenClassrooms-Student-Center/7008001-Debutez-avec-React.git

然后

npm install --verbose

但这行不通。 这是输出:

npm verb cli   '/home/lblk/.nvm/versions/node/v17.6.0/bin/node',
npm verb cli   '/home/lblk/.nvm/versions/node/v17.6.0/bin/npm',
npm verb cli   'install',
npm verb cli   '--verbose'
npm verb cli ]
npm info using npm@8.5.1
npm info using node@v17.6.0
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/home/lblk/.nvm/versions/node/v17.6.0/lib/node_modules/npm/npmrc Completed in 0ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/home/lblk/Documents/dev/javascript/7008001-Debutez-avec-React/.npmrc Completed in 0ms
npm timing config:load:project Completed in 16ms
npm timing config:load:file:/home/lblk/.npmrc Completed in 0ms
npm timing config:load:user Completed in 0ms
npm timing config:load:file:/home/lblk/.nvm/versions/node/v17.6.0/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 2ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 26ms
npm timing npm:load:configload Completed in 26ms
npm timing npm:load:setTitle Completed in 0ms
npm timing config:load:flatten Completed in 3ms
npm timing npm:load:display Completed in 8ms
npm verb logfile /home/lblk/.npm/_logs/2022-03-18T11_07_46_273Z-debug-0.log
npm timing npm:load:logFile Completed in 7ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 43ms
npm timing arborist:ctor Completed in 1ms
npm timing idealTree:init Completed in 11ms
npm timing idealTree:userRequests Completed in 0ms
npm timing idealTree:#root Completed in 0ms
npm timing idealTree:buildDeps Completed in 2ms
npm timing idealTree:fixDepFlags Completed in 0ms
npm timing idealTree Completed in 15ms
npm timing reify:loadTrees Completed in 16ms
npm timing reify:diffTrees Completed in 1ms
npm timing reify:retireShallow Completed in 1ms
npm timing reify:createSparse Completed in 0ms
npm timing reify:loadBundles Completed in 0ms
npm timing reify:audit Completed in 1ms
npm timing reify:unpack Completed in 0ms
npm timing reify:unretire Completed in 0ms
npm timing build:queue Completed in 0ms
npm timing build:deps Completed in 1ms
npm timing build Completed in 1ms
npm timing reify:build Completed in 1ms
npm timing reify:trash Completed in 0ms
npm timing reify:save Completed in 1ms
npm timing reify Completed in 39ms
npm timing command:install Completed in 41ms
npm verb stack Error: ENOENT: no such file or directory, open '/home/lblk/Documents/dev/javascript/7008001-Debutez-avec-React/package.json'
npm verb cwd /home/lblk/Documents/dev/javascript/7008001-Debutez-avec-React
npm verb Linux 5.13.0-35-generic
npm verb argv "/home/lblk/.nvm/versions/node/v17.6.0/bin/node" "/home/lblk/.nvm/versions/node/v17.6.0/bin/npm" "install" "--verbose"
npm verb node v17.6.0
npm verb npm  v8.5.1
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/lblk/Documents/dev/javascript/7008001-Debutez-avec-React/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/lblk/Documents/dev/javascript/7008001-Debutez-avec-React/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
npm verb exit -2
npm timing npm Completed in 302ms
npm verb code -2

npm ERR! A complete log of this run can be found in:

我搜索了一会儿,但我就是不明白... 您可能已经从我尝试安装的存储库中了解到,我正在学习编码和反应 :)

感谢您的帮助

将您的分支更改为分配分支之一,例如:https://github.com/OpenClassrooms-Student-Center/7008001-Debutez-avec-React/tree/P2C2-Begin

您当前的分支没有错误提示的 package.json 文件,因此您无法安装节点模块

你应该做

npm init

在项目的根目录中。它将创建 package.json 文件等。然后就可以使用npm install