Error: EACCES: permission denied, open '/home/myname/.config/insight-nodejs/insight-yo.json.3782504431' - node.js

When I am trying to install a meanjs template with yo generator sudo yo meanjs, it gives me this error:
/usr/local/lib/node_modules/yo/node_modules/write-file-atomic/index.js:236
throw err
^
**Error: EACCES: permission denied, open '/home/myname/.config/insight-nodejs/insight-yo.json.1173957578'**
<br> at Object.fs.openSync (fs.js:646:18)
at Function.writeFileSync [as sync] (/usr/local/lib/node_modules/yo/node_modules/write-file-atomic/index.js:212:13)
<br> at Conf.set store [as store] (/usr/local/lib/node_modules/yo/node_modules/conf/index.js:142:19)
at Conf.set (/usr/local/lib/node_modules/yo/node_modules/conf/index.js:64:14)
at Insight.set optOut [as optOut] (/usr/local/lib/node_modules/yo/node_modules/insight/lib/index.js:56:15)
<br>at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:206:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
My global nodejs modules is :
'ls -la /usr/local/lib/node_modules total 52'
drwxr-xr-x 13 root root 4096 ديسمب 7 18:01 .
- drwxr-xr-x 5 root root 4096 أكتوب 21 09:53 ..
- drwxr-xr-x 4 nobody ayoub 4096 ديسمب 7 17:54 bower
- drwxr-xr-x 5 nobody ayoub 4096 أكتوب 21 09:59 electron
- drwxr-xr-x 5 nobody ayoub 4096 ديسمب 6 16:42 express-generator
- drwxr-xr-x 19 nobody ayoub 4096 ديسمب 7 18:01 generator-meanjs
- drwxr-xr-x 5 nobody ayoub 4096 نوفمب 8 11:54 grunt
- drwxr-xr-x 6 nobody ayoub 4096 نوفمب 8 11:52 grunt-cli
- drwxr-xr-x 4 nobody ayoub 4096 نوفمب 6 21:15 gulp
- drwxr-xr-x 6 nobody ayoub 4096 نوفمب 8 16:16 gulp-cli
- drwxr-xr-x 5 nobody ayoub 4096 نوفمب 12 14:10 mern-app-generator
- drwxr-xr-x 4 nobody ayoub 4096 نوفمب 8 16:43 yarn
- drwxr-xr-x 4 nobody ayoub 4096 ديسمب 7 17:56 yo
And my operation system is: ubuntu 18.04

It seems like root user cannot access to this file.
Removing sudo before the command walked for me. I mean, just try yo meanjs

could you try this :
sudo npm install -g yo --unsafe-perm=true --allow-root
and then run command to create app
sudo yo meanjs
If still getting error try this:
chown -R $USER $HOME/.npm
sudo chown -R $USER /usr/local/lib/node_modules/yo
sudo yo meanjs
Read more here :
https://github.com/krakenjs/generator-kraken/issues/114#issuecomment-54201366
Ubuntu - nodejs - npm install -g > Error: EACCES: permission denied, mkdir

Try the following command
sudo chown -R $USER:$(id -gn $USER) /home/myname/.config

Related

Getting file permission error in docker container ERROR in [eslint] EACCES: permission denied, open '/app/node_modules/.cache/.eslintcache'

I am trying to create a react app wihout installing anything in my machine and for that I have used this Dockerfile
FROM node:18.12
# Create app directory
WORKDIR /app
# Install app dependencies
COPY package.json package-lock.json ./
RUN npm install
# Bundle app source
COPY . .
EXPOSE 3000
CMD ["sudo", "npm", "start"]
and following is my docker-compose.yml
version: '3'
services:
ui:
build: ./ui
container_name: UI
ports:
- "3000:3000"
volumes:
- "./ui:/app"
- "/app/node_modules"
when I am doing docker-compose up
I am getting the following error
UI | Failed to compile.
UI |
UI | [eslint] EACCES: permission denied, open '/app/node_modules/.cache/.eslintcache'
UI | ERROR in [eslint] EACCES: permission denied, open '/app/node_modules/.cache/.eslintcache'
UI |
UI | webpack compiled with 1 error
and here's the wsl2 file structure and permissions
drwxr-xr-x 5 blank blank 4096 Jan 6 18:40 .
drwxr-xr-x 5 blank blank 4096 Jan 6 18:54 ..
-rw-r--r-- 1 blank blank 310 Jan 6 18:38 .gitignore
-rw-r--r-- 1 blank blank 209 Jan 6 18:55 Dockerfile
-rw-r--r-- 1 blank blank 3359 Jan 6 18:38 README.md
drwxr-xr-x 2 root root 4096 Jan 6 18:40 node_modules
-rw-r--r-- 1 blank blank 665979 Jan 6 18:38 package-lock.json
-rw-r--r-- 1 blank blank 827 Jan 6 18:38 package.json
drwxr-xr-x 2 blank blank 4096 Jan 6 18:38 public
drwxr-xr-x 2 blank blank 4096 Jan 6 18:38 src
thanks.

node: permission denied. How to fix?

The permission for nodejs is showing blank. I am not sure how it got changed. I am not able to remove or start node. How to fix this?
/usr/bin# ls -la | grep node
lrwxrwxrwx 1 root root 45 Feb 1 14:40 corepack -> ../lib/node_modules/corepack/dist/corepack.js
---------- 1 root root 75421096 Feb 1 08:05 node
lrwxrwxrwx 1 root root 4 Jun 26 00:44 nodejs -> node
lrwxrwxrwx 1 root root 38 Feb 1 14:40 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 root root 38 Feb 1 14:40 npx -> ../lib/node_modules/npm/bin/npx-cli.js
/usr/bin# node
-bash: /usr/bin/node: Permission denied
/usr/bin# chmod -v 777 node
chmod: changing permissions of 'node': Operation not permitted
failed to change mode of 'node' from 0000 (---------) to 0777 (rwxrwxrwx)
For me, re-installing node with NVM solved the issue:
Install nvm
nvm install 14
nvm use 14

kubernetes giving error,but code works

every time when deploying this images getting this error`
module.js:540
throw err;
^
Error: Cannot find module '/app/index.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
but code works on pc,I hadn't get error for other deployments they was done this way
dockerfile`
FROM node:8.9
ENV port 3000
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD ["sh", "-c", "node index.js --port=${port}"]
yaml `
output of RUN ls -la after COPY ./app
Step 7/8 : RUN ls -la
---> Running in 9e24667abd49
total 76
drwxr-xr-x 9 root root 4096 Jun 21 07:14 .
drwxr-xr-x 57 root root 4096 Jun 21 07:14 ..
-rw-rw-r-- 1 root root 30 May 31 09:00 .dockerignore
-rw-rw-r-- 1 root root 151 Jun 21 07:14 Dockerfile
-rw-rw-r-- 1 root root 556 Jun 20 15:16 api.yaml
drwxrwxr-x 2 root root 4096 May 23 09:03 controllers
-rw-rw-r-- 1 root root 446 Jun 20 15:18 index.js
drwxrwxr-x 3 root root 4096 May 15 11:27 insert
drwxrwxr-x 3 root root 4096 May 15 11:27 modules
drwxr-xr-x 69 root root 4096 Jun 20 15:07 node_modules
-rw-r--r-- 1 root root 20404 Jun 20 15:07 package-lock.json
-rw-rw-r-- 1 root root 328 May 31 09:02 package.json
drwxrwxr-x 2 root root 4096 May 15 11:27 services
drwxrwxr-x 2 root root 4096 Jun 14 14:56 settings
drwxrwxr-x 2 root root 4096 May 23 09:35 utilities
just forget this!!I've tagged the same container as new version,pushed and its works!
Answered by Grigor:
I've tagged the same container as new version,pushed and its works!

webpack unable to resolve node module in docker image

#Dockerfile
FROM node:alpine
RUN mkdir /morty
ADD . /morty/
WORKDIR /morty/
RUN yarn cache clean && yarn install
RUN ls node_modules | grep autosuggest
RUN find /morty/node_modules/react-autosuggest -ls
CMD npm run dev
This builds as expected, but as soon as I request a page from the dev server, I get an error
ERROR in ./src/components/molecules/AutoSuggest/index.js
web_1 | Module not found: Error: Can't resolve 'react-autosuggest' in '/morty/src/components/molecules/AutoSuggest'
web_1 | #
which would suggest to me that for some reason, the react-autosuggest module was not installed; however, the output of step 6 & 7 in my Dockerfile seems to invalidate that hypothesis.
Step 6/7 : RUN ls node_modules | grep autosuggest
---> Running in 0c87c4318a6f
react-autosuggest
Step 7/9 : RUN find /morty/node_modules/react-autosuggest -ls
---> Running in 498c6b9080c7
12042711 4 drwxr-xr-x 3 root root 4096 Mar 6 16:40 /morty/node_modules/react-autosuggest
12042729 4 drwxr-xr-x 3 root root 4096 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist
521128 4 -rw-r--r-- 1 root root 1735 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/theme.js
12042731 4 drwxr-xr-x 2 root root 4096 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/standalone
521127 36 -rw-r--r-- 1 root root 33193 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/standalone/autosuggest.min.js
521126 112 -rw-r--r-- 1 root root 113248 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/standalone/autosuggest.js
521123 28 -rw-r--r-- 1 root root 27217 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/Autosuggest.js
521124 4 -rw-r--r-- 1 root root 65 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/index.js
521121 24 -rw-r--r-- 1 root root 24423 Mar 6 16:40 /morty/node_modules/react-autosuggest/README.md
521129 8 -rw-r--r-- 1 root root 4195 Mar 6 16:40 /morty/node_modules/react-autosuggest/package.json
521120 4 -rw-r--r-- 1 root root 1088 Mar 6 16:40 /morty/node_modules/react-autosuggest/LICENSE
package.json does contain the entry "react-autosuggest": "^9.3.4", in dependencies and the app performs as expected in its un-containerized form.
also, possibly relevant is that the base config for this project came from
the Arc project
I also faced this issue while trying to build my npm project using a container which had WORKDIR as a mounted volume. I resolved this issue by removing the mounted volume by name.
docker volume ls to list the volumes
DRIVER VOLUME NAME
local myproject_named_volume
docker volume rm -f myproject_named_volume to remove the volume
Hope this helps.

Easyrtc gives socket.io.js file issue for the html of the site

The same question is available on easyrtc forum
https://easyrtc.com/forums/viewthread/167/
I was trying to implement the demo provided here : https://demo.easyrtc.com/demos/demo_audio_video_simple.html
Following steps as given in the below link
https://easyrtc.com/docs/guides/easyrtc_server_install.php
—-
Install Node.js
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
—-
I am at logged in as root user
root#pbx:/var/www/html#
I did not get any erorr while running above commands
After running the above commands , I went to the second step
——-
2. Create folder hold the EasyRTC application
ex: sudo mkdir /var/nodes
ex: sudo mkdir /var/nodes/easyrtc
—-
I created a folder /var/nodes/easyrtc as given in example
Should I create instead on /var/www/html (where my domain is pointed to)
—-
3. Security Considerations (not going into specifics)
Create user for node.js (or use existing web user)
chown the nodes folder to be owned by this user
ensure the node is run as that user.
—-
Skipping above step since I am already logged in as root.
Please point out how I could verify the three things mentioned above.
———
Download files from the server_example(https://github.com/priologic/easyrtc/tree/master/server_example) folder into your EasyRTC application folder.
OR download and extract this .zip
—-
Does ‘EasyRTC application folder’ mentioned above indicate /var/nodes/easyrtc ?
https://github.com/priologic/easyrtc/tree/master/server_example
root#PBXRecptionist2:/var/nodes/easyrtc# ls
easyrtc-master master.zip package.json README.md server.js static
After downloading the files I get the above in the easyrtc folder
—
Change to the easyrtc folder and then install node modules locally
cd /var/nodes/easyrtc
sudo npm install
—
following the other instructuion
It added node_modules folder with modules as given below
root#PBXRecptionist2:/var/nodes/easyrtc/node_modules# ls
easyrtc express socket.io
—-
Running EasyRTC Server
From Console
Open your console on the server.
In Windows you can use the provided Node.js console program located in the Start Menu.
Navigate to your EasyRTC application folder
Run the server using the node command.
node server.js
—
What does “Open your console on the server.
” mean?
I am logged in via ssh
should I type command “node ” which opens a node console ??
Does “Navigate to your EasyRTC application folder” this mean moving to /var/nodes/easyrtc ?
When I do this “Run the server using the node command.” ,
node.js on /var/nodes/easyrtc
I get the following error
root#PBXRecptionist2:/var/nodes/easyrtc# node server.js
module.js:340
throw err;
^
Error: Cannot find module ‘../’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/var/nodes/easyrtc/server.js:5:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
and if I do it
root#PBXRecptionist2:/var/nodes/easyrtc# node
node server.js
...
I dont get anything
can anybody point where I am going wrong
Also I get an error that” Your HTML has not included the socket.io.js library”
I am unsure how can I locate the socket.io.js library
My index.html for which I get the above error is
ABCTELECOMMUNICATION: Simple Audio and Video Chat
[removed][removed]
[removed][removed]
[removed][removed]
Not yet connected…
Connected users:
<div id=“otherClients”></div>
</div>
<div id=“videos”>
<video autoplay=“autoplay” class=“easyrtcMirror” id=“selfVideo” muted=“muted” volume=“0” ></video>
<div >
<video autoplay=“autoplay” id=“callerVideo”></video>
</div>
<!—each caller video needs to be in it"s own div so it"s close button can be positioned correctly—>
</div>
</div>
files in the same directory as on the index.html are
drwxr-xr-x 7 root root 4.0K Mar 22 09:14 node_modules
-rw-r—r—1 root root 603 Mar 22 09:08 server.js
-rw-r—r—1 root root 1.2K Mar 22 08:49 index.html
drwxr-xr-x 2 root root 4.0K Mar 22 08:44 easyrtc
-rw-r—r—1 root root 1.2K Mar 21 15:23 index.html~
-rw-r—r—1 root root 170 Mar 20 12:02 socket.io.zip
-rw-r—r—1 root root 1.4K Mar 17 09:50 server.crt
-rw-r—r—1 root root 1.2K Mar 17 09:47 server.csr
-rw-r—r—1 root root 1.7K Mar 17 09:31 server.key
-rw-r—r—1 root root 1.8K Mar 17 09:30 server.key.secure
drwxr-xr-x 2 root root 4.0K Feb 21 10:15 js
drwxr-xr-x 2 root root 4.0K Feb 21 10:00 easyrtc-master
-rw-r—r—1 root root 695K Feb 21 10:00 master.zip
drwxr-xr-x 3 root root 4.0K Aug 24 2015 api
drwxr-xr-x 5 root root 4.0K Aug 24 2015 demos
drwxr-xr-x 3 root root 4.0K Aug 24 2015 dev
drwxr-xr-x 4 root root 4.0K Aug 24 2015 docs
-rw-r—r—1 root root 100 Aug 24 2015 index.js
drwxr-xr-x 2 root root 4.0K Aug 24 2015 lib
-rw-r—r—1 root root 1.4K Aug 24 2015 LICENSE
-rw-r—r—1 root root 932 Aug 24 2015 package.json
-rw-r—r—1 root root 5.7K Aug 24 2015 README.md
drwxr-xr-x 3 root root 4.0K Aug 24 2015 server_example
Can someone help me debug and make the easyrtc work?

Resources