Publish npm, and after installation on other PC have error - node.js

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

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.

Related

Node dependencies error: ENOTEMPTY: directory not empty

I have a problem with local dependencies. I don't understand how to fix it.
You can see all steps to reproduce my error.
Someone have an idea ? Thank a lot
Steps to reproduce
$ npm i --prefix module-a
OK
$ npm i --prefix module-b
OK
$ npm i --prefix module-c
npm WARN tar ENOENT: no such file or directory, open 'module-c/node_modules/.staging/...'
npm WARN tar ENOENT: no such file or directory, open 'module-c/node_modules/.staging/...'
npm WARN tar ENOENT: no such file or directory, open 'module-c/node_modules/.staging/...'
...
npm ERR! code ENOTEMPTY
npm ERR! syscall rmdir
npm ERR! path module-c/node_modules/.staging/core-js-pure-7ef16f00
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rmdir 'module-c/node_modules/.staging/core-js-pure-7ef16f00'
Env
$ npm -v
6.14.6
$ node -v
v10.22.1
Files
module-a/package.json
{
"name": "aaa",
"main": "index.js"
}
module-b/package.json
{
"name": "bbb",
"main": "index.js",
"dependencies": {
"aaa": "file:../module-a"
}
}
module-c/package.json
{
"name": "ccc",
"main": "index.js",
"dependencies": {
"aaa": "file:../module-a",
"bbb": "file:../module-b"
}
}
For you information, I have try with npm link. This solution work on my dev env but it doesn't work on other environnements because build and run are executed on 2 differents servers (so run server doesn't have bbb package in global packages and I have the error Cannot find package bbb).
module-c/package.json
{
"name": "ccc",
"main": "index.js",
"script": {
"postinstall": "cd ../module-b && npm link && cd - && npm link bbb"
},
"dependencies": {
"aaa": "file:../module-a"
}
}

Google Cloud: Create A Simple Application With the API samples npm install failed

Following the instruction from here, https://cloud.google.com/bigquery/create-simple-app-api
cd to the samples folder
https://github.com/googleapis/nodejs-bigquery/tree/master/samples
The package.json is
https://github.com/googleapis/nodejs-bigquery/blob/master/samples/package.json
{
"name": "nodejs-docs-samples-bigquery",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"repository": "googleapis/nodejs-bigquery",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "repo-tools test run --cmd npm -- run cover",
"ava": "ava -T 3m --verbose test/*.test.js system-test/*.test.js",
"cover": "nyc --reporter=lcov --cache ava -T 3m --verbose test/*.test.js system-test/*.test.js && nyc report"
},
"dependencies": {
"#google-cloud/bigquery": "1.2.0",
"#google-cloud/storage": "1.5.1",
"yargs": "10.0.3"
},
"devDependencies": {
"#google-cloud/nodejs-repo-tools": "2.1.3",
"ava": "0.24.0",
"nyc": "11.3.0",
"proxyquire": "1.8.0",
"sinon": "4.1.3",
"uuid": "3.1.0"
}
}
I run
npm install
I get errors
Home-iMac:samples user1$ npm install
npm WARN #google-cloud/bigquery#1.2.0 had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.
npm ERR! path /Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is' -> '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#sindresorhus/is-79439449'
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/user1/.npm/_logs/2018-04-27T19_38_14_391Z-debug.log
To fix the error, a hack solution is instead of using the package.json to install, I have to run this manually first
npm install --save #google-cloud/bigquery
Then I can run
npm install
again. This time, it will finish without problem.
But I would like to be able to just simply using package.json, using npm install only to install the packages.
I changed the package.json
From
"#google-cloud/bigquery": "1.2.0",
to
"#google-cloud/bigquery": "^1.2.0",
It still does not work.
Thanks!
#Tim - Thanks for the request to update, #google/bigquery 1.3.0 is being used for the example. The download link to the GitHub site was updated, but the sample code on the page itself is not updated.

Can't install any npm packages

I can't install any npm packages. I type in npm install lodash and I get:
npm WARN webdev#1.0.0 No description
npm WARN webdev#1.0.0 No repository field.
npm ERR! path C:\Users\Blake\Desktop\webdev\node_modules\lodash
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Blake\Desktop\webdev\node_modules\lodash' -> 'C:\Users\Blake\Desktop\webdev\node_modules\.lodash.DELETE'
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! C:\Users\Blake\AppData\Roaming\npm-cache\_logs\2018-03-15T21_28_45_978Z-debug.log
My package.json file looks like:
{
"name": "webdev",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
I'm not sure what is wrong. I've tried uninstalling and reinstalling node.js. My npm version is 5.6.0. This happens with every package I've tried to install. Please help, I've been trying to fix this for hours to no avail.
EDIT: I fixed it! The absolute nightmare of a program, MalwareBytes Antimalware was blocking it. I quit out of MalwareBytes and now it is working. Not the first time that program has messed up my coding.
Delete package.json and package-lock.json file, use npm init and try again.
Probably directory node_modules doesnt exist in your project working directory
I would make sure you have npm installed locally in your working directory by running npm init. I would also try re-installing npm.
EDIT:
Remove MalwareBytes Anti-Malware.

Use dependencies from a private GitLab with NPM

I'm trying to install NPM dependencies from a private GitLab instence.
So, I have my repo with basic files
And I added this dependencie in the package.json on my project
"node-demo-package": "https://oauth2:<ACCESS TOKEN>#gitlab.fullurl.git"
But, when I run npm install, I receive this error message:
npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: node-demo-package#https://oauth2:<ACCESS TOKEN>#gitlab.fullurl.git.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/arnaud.delante/.npm/_logs/2018-01-24T15_05_49_456Z-debug.log
Which I don't understand as there is a package.json as showed in the screenshot.
Here it is
{
"name": "demo-package",
"version": "1.0.0",
"description": "Test pasckage",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git#gitlab.fullurl.git"
},
"author": "Arnaud Delante",
"license": "MIT"
}
I already tried switching https by git+https but I get another error
npm ERR! Error while executing:
npm ERR! /usr/local/bin/git ls-remote -h -t https://oauth2:<ACCES TOKEN>#gitlab.fullrul.git
npm ERR!
npm ERR! remote: You are not allowed to download code from this project.
npm ERR! fatal: unable to access 'https://oauth2:<ACCES TOKEN>#gitlab.fullrul.git': The requested URL returned error: 403
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/arnaud.delante/.npm/_logs/2018-01-24T17_19_16_677Z-debug.log
Which is weird because the token is correct.
Would you have any idea?
In package.json try to replace https:// by git+https://
doc : https://docs.npmjs.com/files/package.json#git-urls-as-dependencies

why I am unable to publish my package to npmjs

I have created an account with npmjs.com also I'm following the how-to-npm tutorial from command line (linux). I'm at the stage where I should publish my test module. But I keep getting error:
You must sign up for private packages : #zentech/node
these are all the error when npm publish
npm ERR! publish Failed PUT 402
npm ERR! Linux 4.10.0-33-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "publish"
npm ERR! node v4.7.2
npm ERR! npm v3.5.2
npm ERR! code E402
npm ERR! You must sign up for private packages : #zentech/node
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/george/node/npm-debug.log
my package.json file
{
"name": "#zentech/node",
"version": "1.0.1",
"main": "index.js",
"preferGlobal": true,
"scripts": {
"test": "node test.js"
},
"author": "",
"license": "ISC",
"description": "",
"repository": "http://github.com/zentech/node"
}
does anyone know why the error? thanks
As suggested in the comments above the way to publish a scoped package i.e.
#scope/my-package
is to use the --access flag when publishing
npm publish --access=public
You do not need to sign up for private packages unless you actually want your package to be private.
Or you can set the public access on package.json:
{
...
"publishConfig": {"access": "public"}
...
}
rather than:
{
...
"publishConfig": {"access": "restricted"}
...
}
You must sign up for private packages: #zentech/node
So you either sign up, or you change the name of your package from #zentech/node to a public name, like zentech-node.

Resources