npm package.json bin chmod error - node.js

I have created an npm package and I am trying to install it from a git repository. Everything works fine when I run npm install /path/to/package/ --no-bin-links, but I have my package.json set up to link the main JS file into bin. When I try to install the package normally, I get the following error:
npm ERR! path /staging/webshares/proj-test/node_modules/jkvc-project/index.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! enoent ENOENT, chmod '/staging/webshares/proj-test/node_modules/jkvc-project/index.js'
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.
The index.js file definitely exists, and everything in my package.json looks normal:
{
"name": "jkvc-project",
"version": "1.0.0",
"description": "JKD Project Build Tool",
"dependencies": {
"bower": "^1.4.1",
"mkdirp": "^0.5.0",
"optimist": "~0.6.0",
"prompt": "~0.2.12",
"q": "~1.0.0",
"request": "~2.33.0"
},
"files": [
"./scss"
],
"bin": "./index.js"
}
I have tried npm cache clean, but it didn't help. I also have a blank .npmignore file in the directory.
Does anyone know what it causing this chmod error, and how to fix it?
This is the folder structure of my package:
scss
.gitignore
.npmignore
index.js
package.json

Related

npm start errors with ERR! code ENOENT, syscall open

I'm suddently having a problem with "npm start" in my React application. When I trigger it, this is what I receive:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
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! /home/palnic/.npm/_logs/2020-02-20T11_30_39_463Z-debug.log
This is the debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm#6.13.7
3 info using node#v12.13.1
4 verbose stack Error: ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
5 verbose cwd /mnt/c/Users/pal/Desktop/dev/myApp/package.json
6 verbose Linux 4.4.0-18362-Microsoft
7 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
8 verbose node v12.13.1
9 verbose npm v6.13.7
10 error code ENOENT
11 error syscall open
12 error path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
13 error errno -2
14 error enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -2, true ]
I tried the following solution:
sudo npm install -g npm //(ok!)
sudo npm cache clean //(not working if not using --force flag)
And then npm install returns:
npm WARN saveError ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN myApp No description
npm WARN myApp No repository field.
npm WARN myApp No README data
npm WARN myApp No license field.
up to date in 0.454s
found 0 vulnerabilities
My npm version is: 6.13.7
This is my package.json
{
"name": "myApp",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.4.0",
"#testing-library/user-event": "^7.2.1",
"firebase": "^7.7.0",
"node-sass": "^4.13.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"react-stripe-checkout": "^2.6.3",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"styled-components": "^5.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
ADo you have any ideas on the possible causes and the possible solutions?
Just cd to the app directory where package.json is and run npm start again.
I think
you forgot to open a terminal inside the project folder
so solution is change directory to your path where your package.json file is
My project folder is Currency not CurrancyConverter
cd currency
this is best solution which i found !!!
This is because you have done
npm install
and
npm start
from outside the project directory to overcome this issue.
first do
cd project-name
then do
npm install
npm start
I hope this will solve your issue because it works for me.
Your stated error:
npm WARN saveError ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN myApp No description
npm WARN myApp No repository field.
npm WARN myApp No README data
npm WARN myApp No license field.
You can check the bold lines. It explains that you are not in the directory which contains the package.json file.
Most of the times you should run this command in the app directory. So, you need to cd into the directory which holds package.json then there you can run your commands like npm install, npm start etc.
So, before running these commands please check if you are in the correct directory.
Use cd to the home directory of your project (or a directory where package.json is located) and then run the npm start command.
This usually happens while working with terminals.
This is because you are running command outside of project.
cd project_name
npm install
You need to cd (Change directory) into the proper directory where your package.json is.
This is error is only come when we outside the project and try to npm start just make sure you are in the correct folder double-check where package.json file is there.
In my case, I have new app folder in which my-app folder is there so I was confused and thought I am in the correct folder.
so Please make sure you are in the right folder where you are going to enter npm start
I hope it ll work.
it is very small problem
you can easily overcome this problem by changing the directory of the folder
you can
see here that I made a mistake in the directory because I am trying to run npm in to the react-proj but I already made a folder called quiz-app so I changed the directory by writing cd {folder name} like cd quiz-app
then run the file
npm start
I hope it will solve your problem
After successful installation, navigate to the cd project-name and then do
npm start
If you are in the right directory and your project is in a shared folder in virtual box and your error shows up due to a missing package.json file in one of the modules folder like below, then it has nothing to do with npm or package-lock, and something to do with virtual box shared folders.
Here is my error.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path <project_location>/node_modules/yargs/node_modules/string-width/package.json.3307748328
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '<project_location>/node_modules/yargs/node_modules/string-width/package.json.3307748328'
I found that this is a well known issue here with a lot of good suggestions on how to fix it.
https://github.com/npm/npm/issues/992
I ended up using this one:
https://github.com/npm/npm/issues/992#issuecomment-289935776
If you are trying npm start in correct directory and it doesn't worked yet, I was same issue. My directory was (...)/web/ web so I changed the local of my project to (...)different_name_subdirectory/web and it worked for me
You probably are in one external file. You have to start the project in the inner file of the project. pay attention to the command line.
like this
error : C:\projects\file A\file B...\fileX
solve:C:\projects\file A\file B...\fileX\reactFile
I get the same error but not the directory problem.
In my case, I put Wrong Environment Variable declare in .env file.
So, if you face the exact same problem but not directory problem, please check your .env (environment variable) of your project.
Might be you are not starting your React app from source folder.
Error: npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\rn-starter/package.json
you need to check where is your source code is located.
I had this same exact issue, but if you go back an reinstall it, you’ll see that the instructions say to make sure that your user path is localized. Once I switched my path to localized and entered npm i into the terminal, it installed no problem.
Check if there is package.json file or not if not then run npm init and fill the details.
I got this error while installing nodemon package and when I created index.js file or any js file it didn't throw me error.
You can cd to the root folder and then once again cd to the app directory where the package.json is there.
start the npm in your folder where you create react app.
example:
enter image description here
the same issue occur on my project terminal when i am install npm start because my project path was not correct then i am cd command and go to in coorect path of path then my issue was solve
There can be one or more reason, but following solution could help you.
If you initialize npm install without having
package.json
file then, it will give you such error.
Because npm needs some information which is stored in package.json file.
For this you can write
npm init -y
This will create a new package.json file and now you can write npm.
Encountered the same error.
Root Cause:
Not installing(npm i) and starting(npm start) from the correct path
in terminal
Solution:
Change the directory to the application directory where package.json
present
hope this might help, Thanks.
just cd to the folder which you have created which has the project files. Then run npm start.
Solved it!
Just open another cli (CMD, Git bash, node cli) and go to the desired react app folder and run
-npm start
I am assuming you are using vs code with dual server (port) backend and react
I just install the visual studio code and this problem was solved
Also you can check package.json in your project folder. If package.json doesn't exist try to create this or rename package-lock.json.
After that: npm install
in your project folder and
npm run
if you use latest version.
It works to me.
you need to start by initializing npm by using
npm init
after that install npm by using
npm install

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.

Npm rebuild node-sass fails

I have an old project that has a grunt as build tool. I have installed the project dependencies and grunt cli. This is the package.json file:
{
"name": "",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-sass": "^1.0.0",
"node-sass": "^3.3.3"
}
}
On trying to run grunt I got an error that I need to run npm rebuild node-sass, but I got a new error then:
npm ERR! Failed at the node-sass#3.4.2 postinstall script 'node
scripts/build.js'. npm ERR! Make sure you have the latest version of
node.js and npm installed. npm ERR! If you do, this is most likely a
problem with the node-sass package, npm ERR! not with npm itself.
I have even tried with running the command with the --force flag.
But that didn't work either, how can I fix this?

Publish npm, and after installation on other PC have error

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.

Resources