Reputation: 5872
I have a docker container specifically for Ruby on Rails that is basically built from a Ruby docker container. After it runs bundle install and everything else successfully, it then tries to run npm install
which tries to install puppeteer. This is the error I'm receiving below:
sudo docker exec -ti app_1 npm install
> [email protected] install /myapp/node_modules/puppeteer
> node install.js
/myapp/node_modules/puppeteer/install.js:175
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1 npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-21T18_12_14_082Z-debug.log
If I look into the log file printed at the bottom of that output, here's what I see towards the very bottom:
1284 info lifecycle [email protected]~install: [email protected]
1285 silly install [email protected]
1286 info lifecycle [email protected]~install: [email protected]
1287 silly install [email protected]
1288 info lifecycle [email protected]~install: [email protected]
1289 silly install [email protected]
1290 info lifecycle [email protected]~install: [email protected]
1291 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false
1292 verbose lifecycle [email protected]~install: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/myapp/node_modules/puppeteer/node_modules/.bin:/myapp/node_modules/.bin:/usr/local/bundle/bin:/usr/local/bundle/gems/bin:/usr/local/sbin:/usr/local/bin:/usr
/sbin:/usr/bin:/sbin:/bin
1293 verbose lifecycle [email protected]~install: CWD: /myapp/node_modules/puppeteer
1294 silly lifecycle [email protected]~install: Args: [ '-c', 'node install.js' ]
1295 silly lifecycle [email protected]~install: Returned: code: 1 signal: null
1296 info lifecycle [email protected]~install: Failed to exec install script
1297 verbose unlock done using /root/.npm/_locks/staging-bcb8ce459d19ee76.lock for /myapp/node_modules/.staging
1298 warn [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
1299 warn [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
1300 verbose stack Error: [email protected] install: `node install.js`
1300 verbose stack Exit status 1
1300 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
1300 verbose stack at emitTwo (events.js:126:13)
1300 verbose stack at EventEmitter.emit (events.js:214:7)
1300 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 1300 verbose stack at emitTwo (events.js:126:13)
1300 verbose stack at ChildProcess.emit (events.js:214:7)
1300 verbose stack at maybeClose (internal/child_process.js:925:16)
1300 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
1301 verbose pkgid [email protected]
1302 verbose cwd /myapp
1303 verbose Linux 5.4.0-31-generic
1304 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
1305 verbose node v8.9.3
1306 verbose npm v5.5.1
1307 error code ELIFECYCLE
1308 error errno 1
1309 error [email protected] install: `node install.js`
1309 error Exit status 1
1310 error Failed at the [email protected] install script.
1310 error This is probably not a problem with npm. There is likely additional logging output above.
1311 verbose exit [ 1, true ]
According to this GitHub issue, the suggestion was to just simply run npm install puppeteer --unsafe-perm=true
. However, when I ran that, I receive the same exact error.
Still learning Docker, so I'm not quite sure if there is something else that I need to include into the Dockerfile as part of the build. Here's what my Dockerfile looks like:
FROM ruby:2.5.1-alpine
ENV BUNDLER_VERSION=2.0.2
RUN apk add --update --no-cache \
binutils-gold \
build-base \
curl \
file \
g++ \
gcc \
git \
less \
libstdc++ \
libffi-dev \
libc-dev \
linux-headers \
libxml2-dev \
libxslt-dev \
libgcrypt-dev \
make \
netcat-openbsd \
nodejs \
openssl \
pkgconfig \
postgresql-dev \
python \
tzdata \
yarn
RUN gem install bundler -v 2.0.2
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle check || bundle install
COPY . /myapp
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]%
I noticed two warnings about bufferutil
and utf-8-validate
peers being required, and so I installed those successfully, but still ran into the same error
Any suggestions on resolving this npm install puppeteer
issue would be greatly appreciated.
Upvotes: 1
Views: 2053
Reputation: 611
Updating node and npm to these versions solved the problem for me:
$ node -v
v12.17.0
$ npm -v
6.14.4
Upvotes: 2
Reputation: 3059
When we enter npm install puppeteer
it installs the latest version which is 3.1.0
. It seems something wrong with the latest version.
1248 verbose node v8.9.3
1249 verbose npm v5.5.1
1250 error code ELIFECYCLE
1251 error errno 1
1252 error [email protected] install: `node install.js`
1252 error Exit status 1
1253 error Failed at the [email protected] install script.
1253 error This is probably not a problem with npm. There is likely additional logging output above.
1254 verbose exit [ 1, true ]
I tried with version 3.0.0
and it works. So, you can go with version 3.0.0
as a workaround and if you're fine with it.
/ # npm i [email protected]
> [email protected] install /node_modules/puppeteer
> node install.js
(node:145) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): The "original" argument must be of type function
(node:145) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
+ [email protected]
added 49 packages in 3.046s
Upvotes: 1