简体   繁体   English

Npm在错误的目录中搜索package.json

[英]Npm searching for package.json in the wrong directory

Hey I'm trying to install webpack right now. 嘿,我现在正在尝试安装webpack。

I have everything setup, but when I try to run webpack inside my terminal, it searches for the package.json file in the wrong directory. 我已经完成所有设置,但是当我尝试在终端中运行webpack时,它将在错误的目录中搜索package.json文件。

So my question is, can I change the path where npm tries to find my package.json file? 所以我的问题是,我可以更改npm尝试找到package.json文件的路径吗?

npm ERR! enoent ENOENT: no such file or directory, open '/home/User/package.json

^error message I get after trying to run npm webpack in Terminal 尝试在终端中运行npm webpack后收到的^错误消息

{
  "name": "package",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "es6-promise": "^4.1.1",
    "react": "^16.2.0",
    "react-dom": "^16.2.0"
  }
}

^this is the package.json file from my project ^这是我项目中的package.json文件

You are in the wrong directory. 您在错误的目录中。

Make sure you are in the right folder and then run npm install webpack . 确保您在正确的文件夹中,然后运行npm install webpack

In your terminal use pwd to print the current working directory and then ls to list all the files inside it. 在您的终端中,使用pwd打印当前工作目录,然后使用ls列出其中的所有文件。 If there is no package.json you can't install anything. 如果没有package.json ,则无法安装任何程序。

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

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