0

I recently had some issue with the web project on which I'm working and tried to remove node_modules folder. But after removing and reinstalling it from a scratch, I can't build a project at all, not for development neither in production. When I run npm run dev I get the following error:

macbook:coolapp-web-fe.v2 anatolyt$ PORT=8087 npm run dev

> coolapp@2.0.45 dev /Users/anatolyt/work/coolapp-web-fe.v2
> webpack-dev-server --inline --watch --progress --config build/webpack.dev.conf.js

 19% building modules 82/115 modules 33 active ...partials/pages-carcass/flex-block.vue{ parser: "babylon" } is deprecated; we now treat it as 65% building modules 506/548 modules 42 active .../partials/table/colorBarVariables.vue^C^C^C
macbook:coolapp-web-fe.v2 anatolyt$ PORT=8087 npm run dev

> coolapp@2.0.45 dev /Users/anatolyt/work/coolapp-web-fe.v2
> webpack-dev-server --inline --watch --progress --config build/webpack.dev.conf.js

 19% building modules 82/115 modules 33 active ...src/components/partials/card-wrap.vue{ parser: "babylon" } is deprecated; we now treat it as 63% building modules 499/564 modules 65 active ...2/node_modules/moment/locale/zh-hk.js^C^C^C
macbook:coolapp-web-fe.v2 anatolyt$ PORT=8087 npm run dev

> coolapp@2.0.45 dev /Users/anatolyt/work/coolapp-web-fe.v2
> webpack-dev-server --inline --watch --progress --config build/webpack.dev.conf.js

 19% building modules 82/115 modules 33 active ...rc/components/partials/form-group.vue{ parser: "babylon" } is deprecated; we now treat it as 65% building modules 986/1057 modules 71 active ...headerGroup/headerGroupWrapperComp.js

When I build a project for the development (building Docker's image) by running the following code:

FROM node:8-alpine as builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
RUN npm i --production

On last line RUN npm i --production I get the following error:

npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/core-js-967e32e1/client/library.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/vue-form-wizard-25ea249a/src/components/WizardButton.vue'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/vue-form-wizard-25ea249a/src/components/WizardStep.vue'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/ag-grid-vue-df63d144/gulpfile.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/ag-grid-vue-df63d144/LICENSE.txt'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/ag-grid-vue-df63d144/main.js'

I understand that it's too broad error and the various issues can cause to it, but at least some tips how can I debug this issue would be helpful. I tried to remove packaga-lock.json but it didn't help.

Anatoly
  • 5,056
  • 9
  • 62
  • 136

1 Answers1

0

Ok, I found the reason why Docker's image wasn't building with the following error:

npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/vue-form-wizard-25ea249a/src/components/WizardStep.vue'

We have a private npm module which requires that username and password will be specified in .npmrc file. I forget to include this file in Docker image.

When I changed the following line:

COPY package.json package-lock.json ./

to

COPY package.json package-lock.json .npmrc ./

Everything began to work.

The only issue which remained, if I remove a package-lock.json and run npm install from the scratch npm run dev command hangs later. When I restore a package-lock.json older version from a git, it works fine. It's definitely packet conflicts, but I can't understand which one right now.

UPDATE Regarding package-lock.json issue. It's created at the point when npm install was run fist time and it keeps dependencies relevant at that point of time, read here what does it do for details. Since then some dependencies have been changed and this caused to breaking changes. You can compare package-lock.json generated then and now, see the differences in versions and try to catch one which breaks the building. Another option is to use this fork of npm npm install --time-machine (ignore packages released after a given date) and try to run npm install at different point of time to look when the issue begins. I haven't used it yet, but hopefully will use it and will update my answer here.

Anatoly
  • 5,056
  • 9
  • 62
  • 136
  • Delete your lock files, and remove the package-lock.json from your command lines above. The run npm install. Does it throw the same errors? – Scornwell Sep 15 '19 at 09:16
  • Yes, it doesn't work when with a fresh install. I'm going possibly to use this `npm fork` https://github.com/npm/npm/pull/12995 – Anatoly Sep 15 '19 at 12:27