Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node/NPM is updating package.json and package-lock.json file in my home directory instead of project directory

I want to play around with a simple babylonjs toy project and I created a directory on my computer for it at ~/workspace/babylon-test. I then navigate to that directory. So the commands look like this:

mkdir ~/workspace/babylon-test
cd ~/workspace/babylon-test

I use pwd to verify that I am currently inside the babylon-test directory.

I run the following command, recommended from the Babylon docs, to install the babylonjs modules:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

npm install babylonjs --save

I go to inspect my current directory (babylon-test) and it’s empty:

$ pwd
/Users/myuser/workspace/babylon-test
$ ls -al
total 0
drwxr-xr-x   2 myuser  staff    64 Apr 18 13:05 .
drwxr-xr-x  47 myuser  staff  1504 Apr 18 13:05 ..

However, it seems package.json and package-lock.json were created or updated in my home directory:

$ ls -al ~
total 22720
drwxr-xr-x+ 137 myuser  staff     4384 Apr 18 12:58 .
drwxr-xr-x    5 root     admin      160 Apr  9  2018 ..
<lots of files and subdirectories listed here, omitting for brevity and scope>
drwxr-xr-x  780 myuser  staff    24960 Apr 18 21:20 node_modules
-rw-r--r--    1 myuser  staff   896008 Apr 18 21:14 package-lock.json
-rw-r--r--    1 myuser  staff      148 Apr 18 13:06 package.json

Looking at ~/package.json I see its contents are:

{
  "devDependencies": {
    "@vue/cli-plugin-router": "~4.5.0",
    "electron": "^13.1.4"
  },
  "dependencies": {
    "babylonjs": "^5.2.0"
  }
}

I remember trying to install Vue and the Vue CLI several months ago, and I’m wondering if I messed up my Node/NPM configuration somehow.

Shouldn’t I see a package.json and package-lock.json file be generated inside my /workspace/babylon-test directory? And not in my homedir? If so, what can I do to troubleshoot and see what’s going on?

>Solution :

Run npm init first on your pwd and then do npm install
Ref: https://docs.npmjs.com/cli/v8/commands/npm-init

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading