简体   繁体   中英

Webpack build error

UPDATE TL;DR Thank to @sinan-bolel i now know the command

npm ls --depth=0

Which accurately display current installed npm packages. This got me half way. Now to distinguish between working and not working node_modules.

ORIGINAL QUESTION

How do i update my package.json to reflect all local installed packages from my project instead of whats in package.json?

Okay so webpack stopped building without a hint. This occures on desktop called PC_A.

PC_B has a working setup, running from Visual Studio Code ( with powershell ). When PC_A site was destroyed my reaction was, ah easy. Just delete source from PC_A and update from SVN. This restored the files from before the bundling error and should be easy to get back up and running..

Just run npm install to reinstall all node_modules ( which are kept out of SVN ) and you're good to go right? no.

Webpack still generated the same build error after reinstalling with npm install. ( which to my knowledge reads the package.json and installs packages as specified ) Running npm run build generates in the following error:

node_modules\extract-text-webpack-plugin\schema\validator.js:11
            throw new Error(ajv.errorsText());
    ^
Error: data['sourceMap'] should NOT have additional properties

Strange workaround: I zipped my entire node_modules map and transfered it to PC_A and placed it correctly. Now webpack builds just fine. So i think there must be something in node_modules on PC_B which fixes this problem, which is why i want to update my package.json. I do however NOT want to use npm upgrade --save(-dev) because this will update both local packages AND package.json to the LATEST version. I want to fill package.json with local version.

What i've tried:

npm upgrade --save & npm upgrade --save-dev
npm shrinkwrap ( looks promising but doesnt update package.json )
manual updating, tedious and not really scaleable )
npm ls --depth=0 ( works perfect, showing all installed packages! Now to find the culprit )

'Not working node_modules' npm ls --depth=0 produces:

aurelia-skeleton-navigation-webpack@1.0.2 C:\brokenapp
+-- @easy-webpack/config-aurelia@2.2.4
+-- @easy-webpack/config-babel@2.0.4
+-- @easy-webpack/config-common-chunks-simple@2.0.3
+-- @easy-webpack/config-copy-files@1.1.2
+-- @easy-webpack/config-css@2.5.0
+-- @easy-webpack/config-env-development@2.1.6
+-- @easy-webpack/config-env-production@2.2.4
+-- @easy-webpack/config-external-source-maps@2.0.2
+-- @easy-webpack/config-fonts-and-images@1.2.2
+-- @easy-webpack/config-generate-index-html@2.1.1
+-- @easy-webpack/config-global-bluebird@1.3.3
+-- @easy-webpack/config-global-jquery@1.4.1
+-- @easy-webpack/config-global-regenerator@1.3.0
+-- @easy-webpack/config-html@2.0.3
+-- @easy-webpack/config-json@2.0.3
+-- @easy-webpack/config-source-map-support@1.0.2
+-- @easy-webpack/config-test-coverage-istanbul@2.0.3
+-- @easy-webpack/config-typescript@2.1.4
+-- @easy-webpack/config-uglify@2.2.3
+-- @easy-webpack/core@1.4.5
+-- @types/bluebird@2.0.31
+-- @types/d3@4.4.0
+-- @types/jasmine@2.5.43
+-- @types/leaflet@1.0.41
+-- @types/turf@3.5.32
+-- @types/whatwg-fetch@0.0.27
+-- aurelia-bootstrapper-webpack@1.0.0
+-- aurelia-dialog@1.0.0-beta.3.0.1
+-- aurelia-event-aggregator@1.0.0
+-- aurelia-fetch-client@1.0.1
+-- aurelia-framework@1.0.7
+-- aurelia-history-browser@1.0.0
+-- aurelia-loader-webpack@1.0.3
+-- aurelia-logging-console@1.0.0
+-- aurelia-pal-browser@1.0.0
+-- aurelia-polyfills@1.1.1
+-- aurelia-route-recognizer@1.1.0
+-- aurelia-router@1.0.7
+-- aurelia-templating-binding@1.0.0
+-- aurelia-templating-resources@1.1.1
+-- aurelia-templating-router@1.0.0
+-- aurelia-tools@0.2.4
+-- babel-plugin-transform-decorators-legacy@1.3.4
+-- babel-preset-es2015@6.22.0
+-- babel-preset-es2015-loose@7.0.0
+-- babel-preset-es2015-loose-native-modules@1.0.0
+-- babel-preset-stage-1@6.22.0
+-- babel-register@6.23.0
+-- bluebird@3.4.6
+-- bootstrap@3.3.7
+-- concurrently@2.2.0
+-- cross-env@2.0.1
+-- d3@4.3.0
+-- d3-tile@0.0.3
+-- font-awesome@4.7.0
+-- http-server@0.9.0
+-- isomorphic-fetch@2.2.1
+-- jasmine-core@2.5.2
+-- jquery@3.1.1
+-- karma@1.5.0
+-- karma-chrome-launcher@1.0.1
+-- karma-coverage@1.1.1
+-- karma-jasmine@1.1.0
+-- karma-mocha-reporter@2.2.2
+-- karma-remap-istanbul@0.1.1
+-- karma-sourcemap-loader@0.3.7
+-- karma-webpack@1.8.1
+-- leaflet@1.0.1
+-- lodash@4.16.6
+-- moment@2.15.2
+-- protractor@4.0.14
+-- rimraf@2.6.1
+-- topojson@2.2.0
+-- ts-node@1.7.3
+-- turf@3.0.14
+-- typescript@2.1.1
+-- wait-on@1.5.4
+-- UNMET PEER DEPENDENCY webpack@2.1.0-beta.22
`-- webpack-dev-server@2.4.1

npm ERR! peer dep missing: webpack@^2.2.0, required by webpack-dev-server@2.4.1
npm ERR! peer dep missing: webpack@^2.2.0, required by extract-text-webpack-plugin@2.0.0

'Working node_modules' npm ls --depth=0 produces:

aurelia-skeleton-navigation-webpack@1.0.2 C:\app
+-- @easy-webpack/config-aurelia@2.2.3
+-- @easy-webpack/config-babel@2.0.4
+-- @easy-webpack/config-common-chunks-simple@2.0.3
+-- @easy-webpack/config-copy-files@1.1.2
+-- @easy-webpack/config-css@2.5.0
+-- @easy-webpack/config-env-development@2.1.6
+-- @easy-webpack/config-env-production@2.2.4
+-- @easy-webpack/config-external-source-maps@2.0.2
+-- @easy-webpack/config-fonts-and-images@1.2.2
+-- @easy-webpack/config-generate-index-html@2.1.1
+-- @easy-webpack/config-global-bluebird@1.3.3
+-- @easy-webpack/config-global-jquery@1.4.1
+-- @easy-webpack/config-global-regenerator@1.3.0
+-- @easy-webpack/config-html@2.0.3
+-- @easy-webpack/config-json@2.0.3
+-- @easy-webpack/config-source-map-support@1.0.2
+-- @easy-webpack/config-test-coverage-istanbul@2.0.3
+-- @easy-webpack/config-typescript@2.1.4
+-- @easy-webpack/config-uglify@2.2.3
+-- @easy-webpack/core@1.4.5
+-- @types/bluebird@2.0.31
+-- @types/d3@4.4.0
+-- @types/jasmine@2.5.41
+-- @types/leaflet@1.0.41
+-- @types/turf@3.5.32
+-- @types/whatwg-fetch@0.0.27
+-- aurelia-bootstrapper-webpack@1.0.0
+-- aurelia-dialog@1.0.0-beta.3.0.1
+-- aurelia-event-aggregator@1.0.0
+-- aurelia-fetch-client@1.0.1
+-- aurelia-framework@1.0.7
+-- aurelia-history-browser@1.0.0
+-- aurelia-loader-webpack@1.0.3
+-- aurelia-logging-console@1.0.0
+-- aurelia-pal-browser@1.0.0
+-- aurelia-polyfills@1.1.1
+-- aurelia-route-recognizer@1.1.0
+-- aurelia-router@1.0.7
+-- aurelia-templating-binding@1.0.0
+-- aurelia-templating-resources@1.1.1
+-- aurelia-templating-router@1.0.0
+-- aurelia-tools@0.2.4
+-- babel-plugin-transform-decorators-legacy@1.3.4
+-- babel-preset-es2015@6.22.0
+-- babel-preset-es2015-loose@7.0.0
+-- babel-preset-es2015-loose-native-modules@1.0.0
+-- babel-preset-stage-1@6.22.0
+-- babel-register@6.22.0
+-- bluebird@3.4.6
+-- bootstrap@3.3.7
+-- concurrently@2.2.0
+-- cross-env@2.0.1
+-- d3@4.3.0
+-- d3-tile@0.0.3
+-- font-awesome@4.7.0
+-- http-server@0.9.0
+-- isomorphic-fetch@2.2.1
+-- jasmine-core@2.5.2
+-- jquery@3.1.1
+-- karma@1.4.0
+-- karma-chrome-launcher@1.0.1
+-- karma-coverage@1.1.1
+-- karma-jasmine@1.1.0
+-- karma-mocha-reporter@2.2.2
+-- karma-remap-istanbul@0.1.1
+-- karma-sourcemap-loader@0.3.7
+-- karma-webpack@1.8.1
+-- leaflet@1.0.1
+-- lodash@4.16.6
+-- moment@2.15.2
+-- protractor@4.0.14
+-- rimraf@2.5.4
+-- topojson@2.2.0
+-- ts-node@1.7.3
+-- turf@3.0.14
+-- typescript@2.1.1
+-- wait-on@1.5.4
+-- UNMET PEER DEPENDENCY webpack@2.1.0-beta.22
`-- webpack-dev-server@2.2.0

npm ERR! peer dep missing: webpack@^2.2.0, required by webpack-dev-server@2.2.0
npm ERR! extraneous: moment@2.15.1 C:\app\node_modules\wait-on\node_modules\moment

So how do i distinguish between not working and working to locate the package(s) that are causing the error?

You can use the npm ls --depth=0 to list the installed packages for a project.

Run it on PC_A and PC_B, then compare the versions of the packages listed on both machines to those specified in package.json. That will allow you to find any discrepancies.

You can also lock packages to exact versions by removing ^ , >= , etc. from version numbers in package.json dependencies to ensure that the exact version specified in the package.json file is the one that gets installed.

Refer to the semver documentation for more info on versioning standards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM