NPM works differently on the SAME docker image

274 views Asked by At

I can't get assets compilation work on a dev's machine. Here's some specs:

1 Laravel 5.3

2 package.json:

{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch",
    "build": "gulp"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "del": "^2.2.2",
    "eslint": "^4.12.1",
    "eslint-config-standard": "^10.2.1",
    "eslint-plugin-promise": "^3.6.0",
    "eslint-plugin-standard": "^3.0.1",
    "eslint-plugin-vue": "^4.0.0-beta.2",
    "gentelella": "^1.3.0",
    "gulp": "^3.9.1",
    "jquery": "^3.2.1",
    "laravel-echo": "^1.3.0",
    "laravel-elixir": "^6.0.0-15",
    "laravel-elixir-vue-2": "^0.3.0",
    "laravel-elixir-webpack-official": "^1.0.10",
    "laravel-elixir-webpack-react": "^1.0.1",
    "laravel-vue-pagination": "^1.2.0",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "portal-vue": "^1.3.0",
    "pusher-js": "^4.1.0",
    "vue": "^2.4.1",
    "vue-resource": "^1.3.4",
    "vuedraggable": "^2.14.1"
  },
  "dependencies": {}
}

3 My OS: Mac OS X High Sierra.

4 Dev's OS: Debian 9

5 We both have the same node & npm versions installed.

6 I can do both npm install and npm run dev.

7 The dev can only do npm install. The second command produces errors like:

Error: ./resources/assets/js/app.js
Module build failed: TypeError: fileSystem.statSync is not a function
    at module.exports (/home/thedev/Work/lo/project/node_modules/babel-loader/lib/utils/exists.js:7:25)
    at find (/home/thedev/Work/lo/project/node_modules/babel-loader/lib/resolve-rc.js:13:9)

8 Now, the interesting part. In order to make it "the same", I've prepared a docker image. Here's the Dokerfile:

FROM node:alpine

RUN apk update && apk upgrade && \
    apk add --no-cache bash git openssh

9 Building/running the image:

# Host OS:
cd /path/to/project && docker build -t mappanel-npm dev-assets
docker run -v "$PWD":/home/node/app --name=mappanel-npm -it mappanel-npm /bin/bash

# Inside the container:
cd /home/node/app/
rm -rf node_modules package-lock.json
npm install
npm run dev

RESULT: Everything's good on my side (just like running npm on the host). The Dev has the same errors as before!!

[07:34:55] webpack is watching for changes
[07:34:55] 
ERROR in ./resources/assets/js/test.js
Module build failed: TypeError: fileSystem.statSync is not a function
    at module.exports (/home/node/app/node_modules/babel-loader/lib/utils/exists.js:7:25)
    at find (/home/node/app/node_modules/babel-loader/lib/resolve-rc.js:13:9)
    at Object.module.exports (/home/node/app/node_modules/babel-loader/lib/index.js:111:132)

How come?… :/

0

There are 0 answers