尝试运行NPM start时的NPM错误代码

尝试运行NPM start时的NPM错误代码,npm,Npm,当我尝试运行npm start时,我不断收到npm ENONT错误。我不知道该怎么解决这个问题 我已尝试更改文件夹的权限 bryantcaruthers-> npm start npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json npm ERR! errno -2 npm ERR! enoent EN

当我尝试运行npm start时,我不断收到npm ENONT错误。我不知道该怎么解决这个问题

我已尝试更改文件夹的权限

bryantcaruthers-> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bryantcaruthers/.npm/_logs/2019-11-06T03_31_38_233Z-debug.log

能够在没有错误的情况下运行npm start。

错误在于运行代码的目录中没有package.json文件:

no such file or directory, open /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json

您是否希望该目录中有
package.json
文件?或者您应该从其他地方运行npm start。

您可以通过以下方法解决该问题:

确保package.json上正确描述了依赖项 快跑

npm install
检查问题仍然存在。如果问题没有解决,请继续使用这些方法

npm cache clean

sudo npm install -g npm

npm cache clean

npm install

我找到了这个错误的解决办法。发生此错误的主要原因是您没有使用正确的文件夹,请将cd放入安装npm的正确文件夹,或者您可以使用vs代码打开该文件夹。例如,您有一个包含站点或应用程序文件夹的主文件夹,您需要从子文件夹而不是主文件夹工作,这是您安装npm的地方,并且在package.json上正确描述了依赖项。

您的项目
workshop vs code可以做到这一点
没有可用的packeage.json文件,要创建它,请转到terminal(在项目路径上),运行以下命令
npm init-y

尝试运行npm安装,然后通过npm start启动项目