Child module is unable to install dependencies (global install) - Relative path issue? - node.js

I have an npm package with a structure like this:
./
./backend
./package.json
package.json
So basically two npm modules in the same folder, one being a child of the other, file structure wise.
The way I install is, is that I put a post-install script in the parent package.json:
"postinstall": "cd backend && npm install && cd .."
What happens ONLY if I install it globally: It first prints some warnings that basically the packages weren't installed. Like this:
npm WARN enoent ENOENT: no such file or directory, open '/usr/lib/node_modules/inschpektor/backend/node_modules/trim-newlines/package.json'
Those appear for all dependencies in ./backend/package.json.
I already run the installation with the --unsafe-perm flag:
npm install -g inschpektor --unsafe-perm which installs the parent package.json, that contains the postinstall script.
The final log error message I get is this one:
npm ERR! path /usr/lib/node_modules/inschpektor/backend/node_modules/ansi-regex/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/usr/lib/node_modules/inschpektor/backend/node_modules/ansi-regex/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/codepleb/.npm/_logs/2019-01-02T01_52_46_911Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 254
npm ERR! inschpektor#0.9.1 postinstall: `cd backend && npm install && cd ..`
npm ERR! Exit status 254
npm ERR!
npm ERR! Failed at the inschpektor#0.9.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/codepleb/.npm/_logs/2019-01-02T01_52_47_511Z-debug.log
What am I doing wrong? Or do you maybe see flaws in the way I'm setting things up?
Here is the link to get git repo, if you would like to further analyze it: https://github.com/codepleb/inschpektor

Related

Npm run server doest work/ cant run server with

command "npm run serve" doest work, and i get this:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\user/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\user\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: <>br
npm ERR! C:\Users\user\AppData\Local\npm-cache_logs\2022-02-24T23_43_08_331Z-debug-0.log
I tried reinstalling/ installing the node, npm, i tried and didnt work:
npm config set ignore-scripts false
It looks like you are executing NPM from your user home directory. You need to run it in a project directory, and then run npm init, along with the corresponding npm install <X> commands. Do not run init if the project is already initialized.

npm install throwing errors

The code throws the same error when npm install or npm install --save is called.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/andyc/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/andyc/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! /Users/andyc/.npm/_logs/2021-11-04T02_19_18_554Z-debug.log
any idea why this is happening?
It seems you don't have package.json. So, you need to follow these steps, for every new project
Step: 1
npm init --yes
Step: 2
npm i --save 'packagename'
Step: 3 - When you delete and re-install packages by deleting node_modules, run this:
npm i/install

Trouble with installing Nodemon on Windows machine

I have been running into some issues while trying to install nodemon globally.
here's what it looks like:
$ npm i -g nodemon
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\krishnna sarrdah\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\krishnna sarrdah\AppData\Roaming\npm'
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\krishnna sarrdah\AppData\Local\npm-cache\_logs\2021-01-22T16_04_35_377Z-debug.log
Your node installation is slightly out of date, I solved this problem with this
repair Node installation
npm update -g

How to fix npm start errors

I just downloaded a dashboard that uses react.js modules so when get to the dashboards source folder and try to run the command 'npm start' I get the error below:
I tried the following commands but it couldn't work
sudo npm -g uninstall node
npm install node
npm cache clean
sudo npm install -g npm
npm install
npm start
npm ERR! path /home/lamechd/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/lamechd/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/lamechd/.npm/_logs/2019-06-04T09_51_23_106Z-debug.log
NB/ Iam using manjaro Operating System based on archlinux

Invalid package name "node_modules": node_modules is a blacklisted name

I'm having an issue installing npm modules in the client side of my react app. I'm also unable to deploy to Heroku due to this error. Here is the exact error:
`npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "node_modules": node_modules is a blacklisted
name
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.BBwm7/_logs/2018-05-10T14_10_45_520Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grecospie#1.0.0 heroku-postbuild: `cd client/ && npm install &&
npm install --only=dev --no-shrinkwrap && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grecospie#1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.BBwm7/_logs/2018-05-10T14_10_45_552Z-debug.log`
I'm not sure what other info is required as I'm not quite sure what's going on, please let me know what I should add. Also there is no node_modules package in my package.json.
I assume package.json file is missing in your project
IE, you did not run the npm init command when you created the project.
Run npm init from your projects root folder and then
npm Install... for all your packages

Resources