最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Npm searching for package.json in the wrong directory - Stack Overflow

programmeradmin6浏览0评论

Hey I'm trying to install webpack right now.

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.

So my question is, can I change the path where npm tries to find my package.json file?

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

{
  "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

Hey I'm trying to install webpack right now.

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.

So my question is, can I change the path where npm tries to find my package.json file?

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

{
  "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

Share Improve this question edited Dec 26, 2017 at 4:34 KARTHIKEYAN.A 20.2k10 gold badges137 silver badges150 bronze badges asked Dec 24, 2017 at 15:42 SupEldrixSupEldrix 1131 silver badge8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You are in the wrong directory.

Make sure you are in the right folder and then run npm install webpack.

In your terminal use pwd to print the current working directory and then ls to list all the files inside it. If there is no package.json you can't install anything.

发布评论

评论列表(0)

  1. 暂无评论