1

and then install it on other pc to check. Bu after install package and it depencies i have error when try to start it

pm ERR! Linux 4.10.0-38-generic
npm ERR! argv "/home/pavlo/.nvm/versions/node/v6.11.4/bin/node" "/home/pavlo/.nvm/versions/node/v6.11.4/bin/npm" "start" "storjboard"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! path /home/pavlo/Desktop/test/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pavlo/Desktop/test/npm-debug.log

Problem it that i have to clone package.json from git , how i can publish correctly with package.json?

Note: command start inside package.json scripts

My json for publish:

{
  "name": "name",
  "version": "0.0.3",
  "description": "Name",
  "main": "script.js",
  "dependencies": {
    "request": "^2.83.0",
  },
  "devDependencies": {},
  "scripts": {
    "test": "mocha",
    "start": "node node_modules/module/script.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/me/module"
  },
  "keywords": [
    "somewords"
  ],
  "author": "me",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/me/module/issues"
  },
  "homepage": "https://github.com/me/module#readme"
}

Error (WARN) when installing module on other PC

npm WARN enoent ENOENT: no such file or directory, open '/home/pavlo/Desktop/test/package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.

But in test/node_modules/module/(here there are everything) readme, json and script

Beliaf
  • 577
  • 2
  • 8
  • 25
  • It seems you're not launching your start script from your module directory. – TGrif Nov 06 '17 at 08:37
  • yes, but it is possible to launch not from module dir this? In module dir json present – Beliaf Nov 06 '17 at 09:24
  • I go to dir test , there `npm install ` and there try to run `npm start ` But json is in dir `test/node_modules/module` – Beliaf Nov 06 '17 at 09:26
  • Yes it's possible but you have to change your start script to point to the module (something like _node node_modules/yourmodule/script.js_). – TGrif Nov 06 '17 at 09:40
  • changes but the same updated json in question, maybe need somehow path to json file – Beliaf Nov 06 '17 at 09:50
  • No I mean the start script in the package_json file from where you launch the command (test). Or maybe you can try [this](https://stackoverflow.com/a/41772105/5156280). – TGrif Nov 06 '17 at 10:08
  • `"start": "node node_modules/module/script.js"` – Beliaf Nov 06 '17 at 10:14
  • But the error the same module can't find json in test dir, but it have to look in node_module/module/ – Beliaf Nov 06 '17 at 10:20

1 Answers1

0

If you want to be able to start your module from another directory, you can do it like this:

In your module package.json

{
  "name": "module",
  "scripts": {
    "start": "node script.js"
  }
}

from the test directory (as this answer suggest):

npm start --prefix node_modules/module/

Alternately, you can start your module by creating a package.json file in your test directory and adding a script:

{
  "name": "test",
  "scripts": {
    "start": "node node_modules/module/script.js"
  }
}

Usally npm packages are placed in node_modules directory because those modules are supposed to be used as dependencies, not directly.

It depends on the purpose of your application, but maybe you might be interested in doing a post-install script or installing it globally.

npm doc for packages installation.

TGrif
  • 5,725
  • 9
  • 31
  • 52