@@ -110,7 +110,7 @@ main() {
110110 echo " Failed to download cloud agent; --link will not work"
111111 fi
112112
113- if ! vscode_yarn ; then
113+ if ! vscode_install ; then
114114 echo " You may not have the required dependencies to build the native modules."
115115 echo " Please see https://github.com/coder/code-server/blob/main/docs/npm.md"
116116 exit 1
@@ -123,17 +123,44 @@ main() {
123123 fi
124124}
125125
126- vscode_yarn () {
126+ install_with_yarn_or_npm () {
127+ # NOTE@edvincent: We want to keep using the package manager that the end-user was using to install the package.
128+ # This also ensures that when *we* run `yarn` in the development process, the yarn.lock file is used.
129+ case " ${npm_config_user_agent-} " in
130+ yarn* )
131+ if [ -f " yarn.lock" ]; then
132+ yarn --production --frozen-lockfile --no-default-rc
133+ else
134+ echo " yarn.lock file not present, not running in development mode. use npm should be used to install code-server!"
135+ exit 1
136+ fi
137+ ;;
138+ npm* )
139+ if [ -f " yarn.lock" ]; then
140+ echo " yarn.lock file present, running in development mode. use yarn to install code-server!"
141+ exit 1
142+ else
143+ npm install --omit=dev
144+ fi
145+ ;;
146+ * )
147+ echo " Could not determine which package manager is being used to install code-server"
148+ exit 1
149+ ;;
150+ esac
151+ }
152+
153+ vscode_install () {
127154 echo ' Installing Code dependencies...'
128155 cd lib/vscode
129- yarn --production --frozen-lockfile --no-default-rc
156+ install_with_yarn_or_npm
130157
131158 symlink_asar
132159 symlink_bin_script remote-cli code code-server
133160 symlink_bin_script helpers browser browser .sh
134161
135162 cd extensions
136- yarn --production --frozen-lockfile
163+ install_with_yarn_or_npm
137164}
138165
139166main " $@ "
0 commit comments