Mac mini (M1, 2020)
Monterey
Brownie v1.17.2
nodejs v16.13.4
I am learning solidity according to reference(https://www.youtube.com/watch?v=M576WGiDBdQ&t=25510s).
Node.JS install is fine
when I tried this
npm install --global yarn
the terminal give the error information
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/yarn
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/yarn'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/liwei/.npm/_logs/2022-01-08T12_13_37_765Z-debug.log
(base) liwei#liweideMac-mini-2 com~apple~CloudDocs %
I checked the owner of the file ,the owner is root ,should i use sudo?
(base) liwei#liweideMac-mini-2 com~apple~CloudDocs % ls -l /usr/local/lib/node_modules/npm
total 64
-rw-r--r-- 1 root wheel 9742 10 14 08:49 LICENSE
-rw-r--r-- 1 root wheel 4190 10 19 06:36 README.md
drwxr-xr-x 9 root wheel 288 12 1 19:46 bin
drwxr-xr-x 4 root wheel 128 12 1 19:46 docs
-rw-r--r-- 1 root wheel 145 11 23 14:00 index.js
drwxr-xr-x 77 root wheel 2464 12 1 19:46 lib
drwxr-xr-x 5 root wheel 160 12 1 19:46 man
drwxr-xr-x 188 root wheel 6016 12 1 19:46 node_modules
-rw-r--r-- 1 root wheel 6007 12 1 19:13 package.json
drwxr-xr-x 3 root wheel 96 12 1 19:46 tap-snapshots
(base) liwei#liweideMac-mini-2 com~apple~CloudDocs %
find this thread (Error: EACCES: permission denied, access '/usr/local/lib/node_modules'),changed the owner , stll one file don't change.
(base) liwei#liweideMac-mini-2 com~apple~CloudDocs % sudo chown -R liwei: /usr/local/lib/node_modules
(base) liwei#liweideMac-mini-2 com~apple~CloudDocs % ls -la /usr/local/lib/node_modules
total 0
drwxr-xr-x 4 liwei wheel 128 1 8 11:51 .
drwxr-xr-x 4 root wheel 128 1 8 11:51 ..
drwxr-xr-x 7 liwei wheel 224 12 1 19:46 corepack
drwxr-xr-x 13 liwei wheel 416 12 1 19:46 npm
what is this 2 dots is?
reference answer is here
(Error: EACCES: permission denied, access '/usr/local/lib/node_modules')
This works for me very quick.
To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use a hidden directory in your home directory.
Back up your computer. On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a
~/.profile
file and add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
To test your new configuration, install a package globally without using sudo
I had the same problem but I could solve it after seeing a youtube video
use this command:
sudo npm install --global yarn
Related
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir'/usr/local/lib/node_modules/nodemon'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/nodemon'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
Looks like the problem is with the package generator-karma, not sure if this is the problem or not.
Can anyone show me what i need to do to get this installing correctly.
Thanks
Sanil
I believe you're trying to install a global package on your system by using npm install -g nodemon, then got permission denied, which is shown in error message.
You can't install a global package without root permission. If you want to do so, just execute it with root permission, like using sudo: sudo npm i -g nodemon or switch to root then execute again.
This looks like a permissions issue in your home directory. To reclaim ownership of the node_modules directory execute:
sudo chown -R $(whoami) ~/node_modules
Node.js error EACCES means you don't have access to the path it's specifying. In this case, /usr/local/lib/... is owned by the root user. See the command output here:
$ ls -l /usr/local/lib
total 12
drwxr-xr-x 4 root root 4096 Apr 7 23:45 node_modules
Nobody but root is allowed to write to the node_modules folder. This can be solved by prefixing your npm command with sudo to run the command as root.
See other: Understanding Linux File Permissions - Linuxize
This question already has answers here:
NPM modules won't install globally without sudo
(16 answers)
Closed 2 years ago.
I need to install yarn without sudo. I do this:
$ npm install -g yarn
and I get this:
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /usr/bin/yarn
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/bin/yarn'
npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/bin/yarn'] {
npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/bin/yarn'] {
[.........]
But:
ls -al /usr/lib/node_modules/
drwxr-xr-x 5 user1 user1 4096 Sep 15 05:13 .
drwxr-xr-x 63 root root 32768 Sep 14 15:18 ..
drwxr-xr-x 9 user1 user1 4096 Sep 14 14:48 node-gyp
drwxr-xr-x 9 user1 user1 4096 Sep 15 04:22 npm
drwxr-xr-x 7 user1 user1 4096 Sep 14 14:48 semver
And
$ ls -ald /usr/lib/node_modules/
drwxr-xr-x 5 user1 user1 4096 Sep 15 05:13 /usr/lib/node_modules/
Why and how to fix it?
Your config folder must be owned by root, which creates several permissions issue. Changing it to the current user will solve it
$USER:$GROUP -> gives the current login user and the group. in the terminal you can try to echo $USER echo $GROUP to know its value. By this command, it will change to the value present in $USER. The same applies for the group too.
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
now try all your commands
replication of https://github.com/bower/bower/issues/2262
Brand new to VueJS and am trying to install vue-cli as it is my understanding that it is the minimal requirement to build a VueJS application.
I run:
$ npm install --global vue-cli
Unhandled rejection Error: EACCES: permission denied, open '/Users/myuser/.npm/_cacache/tmp/2e41a7b1'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
I found this SO answer here which recommends running:
$ npm i --no-package-lock
npm WARN saveError ENOENT: no such file or directory, open '/Users/myuser/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/myuser/package.json'
npm WARN myuser No description
npm WARN myuser No repository field.
npm WARN myuser No README data
npm WARN myuser No license field.
up to date in 0.374s
found 0 vulnerabilities
╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.9.0 → 6.14.6 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.14.6 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯
So then I go to upgrade npm:
$ npm install -g npm
Unhandled rejection Error: EACCES: permission denied, open '/Users/myuser/.npm/_cacache/tmp/54213b04'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
...and I'm right back to where I started! What's going on here?!
Update
When I try to force a clean cache I also get errors:
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/myuser/.npm/_cacache/content-v2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! [OperationalError: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'] {
npm ERR! cause: [Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: "Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/myuser/.npm/_cacache/content-v2'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
Update regarding potential permissions issue
Remember this is my own user's home directory, so I should absolutely have full access/privilege to use and have been using this laptop for years without any issues.
When I cd into /Users and run ls -al I get:
$ ls -al
total 0
drwxr-xr-x 5 root admin 160 Apr 9 2018 .
drwxr-xr-x 30 root wheel 960 May 2 2019 ..
-rw-r--r-- 1 root wheel 0 Jul 15 2017 .localized
drwxrwxrwt 5 root wheel 160 Apr 9 2018 Shared
drwxr-xr-x+ 117 myuser staff 3744 Jul 11 11:14 myuser
So again this could not possibly be an actual permission issue.
Update for trying to uninstall node and install nvm
I was able to follow this link to manually delete node/npm off my system. I then tried following this link to install nvm and it doesn't seem to work for me:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11329 100 11329 0 0 33913 0 --:--:-- --:--:-- --:--:-- 34123
=> Downloading nvm from git to '/Users/myuser/.nvm'
=> Cloning into '/Users/myuser/.nvm'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 7748 (delta 0), reused 1 (delta 0), pack-reused 7747
Receiving objects: 100% (7748/7748), 2.63 MiB | 1.77 MiB/s, done.
Resolving deltas: 100% (4905/4905), done.
* (HEAD detached at v0.33.0)
master
=> Compressing and cleaning up git repository
Counting objects: 7748, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7684/7684), done.
Writing objects: 100% (7748/7748), done.
Total 7748 (delta 5188), reused 2329 (delta 0)
=> Appending nvm source string to /Users/myuser/.bashrc
=> bash_completion source string already in /Users/myuser/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="/Users/myuser/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
So I close my terminal and restart it and then run:
$ nvm --version
-bash: nvm: command not found
It looks you don't have permission to the directory:
cd /Users/myuser
chown -R $USER ./.npm
And please try again.
If it doesn't work, I recommend to remove your nodejs totally and install nvm and install nodejs using nvm.
This is what appspec.yml looks like:
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/webocitySalonPOS/
owner: ec2-user
permissions:
- object: /home/ec2-user/webocitySalonPOS/
mode: 755
acls:
- "d:u::rwx"
- "d:g::rwx"
- "d:o::rwx"
owner: ec2-user
type:
- directory
- object: /scripts/
mode: 777
acls:
- "d:u::rwx"
- "d:g::rwx"
- "d:o::rwx"
owner: ec2-user
type:
hooks:
AfterInstall:
- location: scripts/autoinstall.sh
timeout: 1000
runas: ec2-user
ApplicationStart:
- location: scripts/autostart.sh
timeout: 300
runas: ec2-user
If I change autoinstall.sh that has npm install in it to be exceuted as root user
AfterInstall:
- location: scripts/autoinstall.sh
timeout: 1000
runas: root
I get:
Script at specified location: scripts/autoinstall.sh run as user root failed with exit code 1
If I execute it as ec2-user, I get:
script at specified location: scripts/autoinstall.sh run as user ec2-user failed with exit code 243
Log Tail[stderr]npm WARN codedeploy-agent No license field.
[stderr]npm ERR! Linux 4.4.8-20.46.amzn1.x86_64
[stderr]npm ERR! argv "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/node" "/home/ec2-user/.nvm/versions/node/v6.11.5/bin/npm" "install"
[stderr]npm ERR! node v6.11.5
[stderr]npm ERR! npm v3.10.10
[stderr]npm ERR! path /opt/codedeploy-agent/node_modules
[stderr]npm ERR! code EACCES
[stderr]npm ERR! errno -13
[stderr]npm ERR! syscall mkdir
[stderr]
[stderr]npm ERR! Error: EACCES: permission denied, mkdir '/opt/codedeploy-agent/node_modules'
[stderr]npm ERR! at Error (native)
[stderr]npm ERR! { Error: EACCES: permission denied, mkdir '/opt/codedeploy-agent/node_modules'
[stderr]npm ERR! at Error (native)
[stderr]npm ERR! errno: -13,
[stderr]npm ERR! code: 'EACCES',
[stderr]npm ERR! syscall: 'mkdir',
[stderr]npm ERR! path: '/opt/codedeploy-agent/node_modules' }
[stderr]npm ERR!
On deployment, permissions for directory
/home/ec2-user/webocitySalonPOS/
look like this:
ls -ltr webocitySalonPOS
total 48
-rw-r--r-- 1 root root 279 Jan 8 11:09 README.md
-rw-r--r-- 1 root root 13940 Jan 8 11:09 Gruntfile.js
-rw-r--r-- 1 root root 1415 Jan 8 11:09 package.json
-rw-r--r-- 1 root root 1432 Jan 8 11:09 bower.json
-rw-r--r-- 1 root root 645 Jan 8 11:09 appspec.yml
-rw-r--r-- 1 root root 85 Jan 8 11:09 afterinstall.sh
drwxr-xr-x+ 3 ec2-user root 4096 Jan 8 11:09 test
drwxr-xr-x+ 2 ec2-user root 4096 Jan 8 11:09 scripts
drwxr-xr-x+ 6 ec2-user root 4096 Jan 8 11:09 app
How do I fix this?
if I build an image like this:
docker build -f app/Dockerfile -t test .
it builds just fine, but the following docker-compose.yml (which I believe should be equivalent):
app:
container_name: test
build:
context: .
dockerfile: app/Dockerfile
fails to build. if I run docker-compose with --verbose I see:
compose.cli.verbose_proxy.proxy_callable: docker build <- (pull=False,
stream=True, nocache=False, tag=u'prj_app', buildargs=None,
rm=True, forcerm=False, path='/Users/ekkis/dev/prj',
dockerfile='./app/Dockerfile')
which would seem pretty much what I expect. specifically the error I'm getting is this (sorry to include as code but quotes make a mess of things):
npm WARN app#1.0.0 No description
npm WARN app#1.0.0 No repository field.
npm ERR! Linux 4.9.12-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "/tmp/inc"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! path /usr/src/app/node_modules/inc
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/usr/src/app/node_modules/inc'
npm ERR! enoent ENOENT: no such file or directory, access '/usr/src/app/node_modules/inc'
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! /usr/src/app/npm-debug.log
as you can see from the above, the Dockerfile performs an npm install /tmp/inc, which from the output I see succeeded since it prints a tree of modules installed. /tmp/inc is created by the Dockerfile command shown below as successful:
Step 8/11 : ADD inc /tmp/inc
---> Using cache
---> fce607bb13ca
and I note that the app/npm-debug.log was not written to, nor is there a log file in the directory where I ran docker compose.
what could be the issue here? why does it build ok manually but not with docker-compose?
* Addendum I *
in my continuing efforts to figure it out, I added a directory listing before the Dockerfile executes the npm install...
Step 9/13 : RUN ls -alF
---> Running in ac0c62b7da93
total 28
drwxr-xr-x 3 root root 4096 Mar 19 07:01 ./
drwxr-xr-x 4 root root 4096 Mar 19 07:01 ../
-rw-r--r-- 1 root root 722 Mar 19 05:48 config.json
-rw-r--r-- 1 root root 3786 Mar 19 05:48 index.js
drwxr-xr-x 119 root root 4096 Mar 17 18:57 node_modules/
-rw-r--r-- 1 root root 2910 Mar 17 20:51 npm-debug.log
-rw-r--r-- 1 root root 416 Mar 19 06:39 package.json
...and, most interestingly, there is already a node_modules directory there!! that means the problem is that docker-compose is not honouring the .dockerignore file (which prevents copying **/node_modules into the context)
so is there some special voodoo I have to perform for the build to generate the context properly?
* Addendum II *
here's my Dockerfile:
FROM node:latest
EXPOSE 8000
ENV PORT 8000
RUN apt-get update
RUN groupadd -r tst && useradd -m -r -g tst tst
WORKDIR /usr/src/app
ADD app /usr/src/app
ADD inc /tmp/inc
RUN npm install --production
RUN npm install /tmp/inc
RUN rm -rf /tmp/inc
CMD ["npm", "start"]
My guess is you don't use --unsafe-perm npm key. Try change npm install to:
RUN npm install --production --unsafe-perm