実現したいこと
Visual Studio Codeの拡張機能である「Dev Containers」ですが、Node.jsでグローバルでのインストールができません。グローバルでのインストール方法が分かる方がいたら教えてほしいです。
前提
Windows11にDocker DesktopをインストールしてVS Code拡張機能の「Dev Containers」を用いたNode.js環境構築したいと考えています。
ところが「npm -g install xxx」を実行すると以下のようなエラーが発生してしまいます。
発生している問題・エラーメッセージ
node@01d8d8c9a795:/workspaces/test$ npm install -g npm@10.1.0 npm ERR! code EACCES npm ERR! syscall rename npm ERR! path /usr/local/lib/node_modules/npm npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI' npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'rename', npm ERR! path: '/usr/local/lib/node_modules/npm', npm ERR! dest: '/usr/local/lib/node_modules/.npm-i9nnxROI' 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: /home/node/.npm/_logs/2023-09-23T05_25_36_970Z-debug-0.log
試したこと
以下のように、VS Codeでコンテナの構成ファイルを追加して、「Node.js」を選択しました。
出来上がった2つのファイルです。
devcontainer.json
1// See https://containers.dev/implementors/json_reference/ for configuration reference 2{ 3 "name": "Untitled Node.js project", 4 "build": { 5 "dockerfile": "Dockerfile" 6 }, 7 "remoteUser": "node" 8} 9
Dockerfile
1FROM node:18 2 3# Install basic development tools 4RUN apt update && apt install -y less man-db sudo 5 6# Ensure default `node` user has access to `sudo` 7ARG USERNAME=node 8RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ 9 && chmod 0440 /etc/sudoers.d/$USERNAME 10 11# Set `DEVCONTAINER` environment variable to help with orientation 12ENV DEVCONTAINER=true 13 14} 15
権限が無いんだと思うのですがどのように構築したら良いでしょうか?

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。