用自制程序安装 node.js 时出现问题

我正在尝试用 Homebrew 安装 Node.js (我之前没有使用 brew 安装它,而且我已经尝试删除所有这些文件)。我看过之前提出的类似问题,但我还没能让它们起作用。首先我尝试了 brew link node,它给了我:

myusername@c126h060:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'


To force the link and overwrite all conflicting files:
brew link --overwrite node


To list all files that would be deleted:
brew link --overwrite --dry-run node

然后当我运行 brew link --overwrite node时,我得到以下结果:

myusername@c126h060:~$ brew link --overwrite node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.

此外,当我尝试使用 brew link -n node来查找文件手动删除,我设法删除了其中的一些文件,但我仍然留下了以下文件,我无法删除:

myusername@c126h060:~$ brew link -n node
Would link:
/usr/local/etc/bash_completion.d/npm
/usr/local/bin/node
/usr/local/include/node
/usr/local/share/man/man1/node.1
/usr/local/share/systemtap/tapset/node.stp
/usr/local/lib/dtrace/node.d

当我尝试删除时,我会得到下面的结果(所有这些文件都是一样的) :

myusername@c126h060:~$ rm /usr/local/etc/bash_completion.d/npm
rm: /usr/local/etc/bash_completion.d/npm: No such file or directory

我该怎么办?

45609 次浏览

It may be that you don't actually own your systemtap directory. Navigate to /usr/local/share and run this command in order to make yourself the owner:

chown -R <yourusername>:<yourgroupname> systemtap

When I was fixing this same issue earlier today, I had to also go into /usr/local and do the same thing for the lib directory.

Or, alternatively, verify the ownership and permissions on systemtap

$ ls -al /usr/local/share/systemtap/
drwxr-xr-x   3 root  wheel  102 Oct 23 18:06 .
drwxrwxr-x  15 root  wheel  510 Oct 24 20:24 ..
drwxr-xr-x   2 root  wheel   68 Oct 24 20:17 tapset

then add yourself to the owner group (in this case wheel)

sudo dscl . append /Groups/wheel GroupMembership <username>

then change the permissions on tapset to allow group edits

sudo chmod -R 775 /usr/local/share/systemtap/tapset/
arun:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'

Run below commands

brew postinstall node -v
brew link node

What worked for me:

  1. cd /usr/local/share
  2. sudo chown -R <user>:<group> systemtap (Did 1 & 2 for /usr/local too)

Above steps were failing. Went to next answer. Tried;

ls -al /usr/local/share/systemtap/ which throwed a 'Not found error.'

Then: brew link node was throwing an error. So I did:

  1. sudo rm -rf /usr/local/lib/node_modules
  2. brew postinstall node -v
  3. And at last brew link node
  4. node -v :)

So basically I removed all node_modules/ folders and redid everything.

get your username,

and get your groups:(could be more than one,generally is 'admin')

whoami
groups

then, for exapmle:

sudo chown -R chrislee:admin /usr/local/share/systemtap/

The following recipe worked for me:

  1. Add your username to add group wheel sudo dscl . append /Groups/wheel GroupMembership username
  2. sudo chmod -R 775 /usr/local/share/systemtap/tapset/
  3. sudo rm -rf /usr/local/lib/node_modules
  4. brew cleanup
  5. brew link node
  6. brew uninstall --force node
  7. brew install node

Then check version with node -v and npm -v.

just add sudo in the beginning of the command npm install expo-cli --global

like sudo npm install expo-cli --global and hit enter.

hope it'll help you.

This command was the answer for the error message for me. It changes the folder permissions to the current user:

sudo chown -R $(whoami) /usr/local/share/systemtap