NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

update-ns-webpack, error updating webpack config #1144

Open funder7 opened 3 years ago

funder7 commented 3 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug

Error showing after launching ./node_modules/.bin/update-ns-webpack --configs:

internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module '../projectHelpers'
Require stack:
- **project_dir**/node_modules/@nativescript/webpack/verify/update.js
- **project_dir**/node_modules/@nativescript/webpack/bin/update-ns-webpack
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (**project_dir**/node_modules/@nativescript/webpack/verify/update.js:8:5)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '**project_dir**/node_modules/@nativescript/webpack/verify/update.js',
    '**project_dir**/node_modules/@nativescript/webpack/bin/update-ns-webpack'
  ]
}

(paths are hidden by myself, they're showing correctly in the original output)

To Reproduce I was updating an old project (a plugin), after running npm install i received a notice:

Note: webpack.config.js is different than the suggested @nativescript/webpack config at ..project_dir/node_modules/@nativescript/webpack/templates/webpack.angular.js.
If you have build trouble you can update to latest config using "./node_modules/.bin/update-ns-webpack --configs" command.

Running the suggested command is throwing the error.

Expected behavior

Additional context I was going to open a PR to fix this, unfortunately the github repo doesn't seem to be aligned with the latest npm release (2.1.3), the most updated branch (feat/webpack-updates) is at 2.0.0-alpha.3 ... Please, if possible keep repo's tags aligned in order to let people contribute ;)

Fix

const {
    getPackageJson,
    getProjectDir,
    writePackageJson,
} = require("../projectHelpers");

Replace with:

const {
    getPackageJson,
    getProjectDir,
    writePackageJson,
} = require("../helpers/projectHelpers");