Tag Archives: Npm

[Solved] NPM Start Project Error: ‘Error: error:0308010C:digital envelope routines::unsupported’

Reason: the version of node is higher than 16, the version of the project is not higher than 16, and OpenSSL is updated after node17.

Solution:

Method 1:

Modify the environment variable at the command line: $env:NODE_OPTIONS="--openssl-legacy-provider"
In the start project: yarn start
Method 2.
Use nvm to modify the node to a version no higher than 16

css-rcurlyexpected Error: css-rcurlyexpected at-rule, or selector expected, Do not use empty rulesets

● questions:

● the errors are:

css-rcurlyexpected
at-rule or selector expected
Do not use empty rulesets

But the style works normally.

● cause

1. set “vetur.validation.style”: false in setting.json,
2. add @charset “utf-8” to the first line of style;
But the main reason for this is that the page language mode is set incorrectly, just use the default .vue will be set to html mode, so it will report an error

● Solution 1:

Click in to change to Vue mode

● Solution 2:

Set the setting in setting.json to allow the system to modify the language mode of the .vue file to vue by default

"files.associations": {
   "*.vue": "vue",
 },

[Solved] Found bindings for the following environments

When running the previously written vue project, I encountered the following error.
It should be caused by incompatible version upgrade
Error:

Module build failed: ModuleBuildError: Module build failed: Error: Missing binding E:\SVN\32IDPW\04-project\03-source\02-web\briefing\node_modules\node-sass\vendor\win32-x64-64\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 10.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 8.x

 

Solution:

npm rebuild node-sass

npm update

npm run dev

[Solved] Error Rule can only have one resource source (provided resource and test + include + exclude)

Error: Rule can only have one resource source
(provided resource and test + include + exclude)

Error: Rule can only have one resource source (provided resource and test + include + exclude)

Error: Rule can only have one resource source (provided resource and test + include + exclude) in
 "exclude": [
    null
  ],
  "use": [
    {
      "loader": "/Users/juanpablo/front-treatments/node_modules/cache-loader/dist/cjs.js",
      "options": {
        "cacheDirectory": "/Users/juanpablo/front-treatments/node_modules/.cache/babel-loader",
        "cacheIdentifier": "81fef5a6"
      },
      "ident": "clonedRuleSet-38[0].rules[0].use[0]"
    },
    {
      "loader": "/Users/juanpablo/front-treatments/node_modules/babel-loader/lib/index.js",
      "options": "undefined",
      "ident": "undefined"
    }
  ]
} ````
A complete log of this run can be found in:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/juanpablo/.nvm/versions/node/v12.19.0/bin/node',
1 verbose cli   '/Users/juanpablo/.nvm/versions/node/v12.19.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'serve'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle [email protected]~preserve: [email protected]
6 info lifecycle [email protected]~serve: [email protected]
7 verbose lifecycle [email protected]~serve: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~serve: PATH: /Users/juanpablo/.nvm/versions/node/v12.19.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/juanpablo/front-treatments/node_modules/.bin:/Users/juanpablo/.nvm/versions/node/v12.19.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/juanpablo/.rvm/bin
9 verbose lifecycle [email protected]~serve: CWD: /Users/juanpablo/front-treatments
10 silly lifecycle [email protected]~serve: Args: [ '-c', 'vue-cli-service serve' ]
11 silly lifecycle [email protected]~serve: Returned: code: 1  signal: null
12 info lifecycle [email protected]~serve: Failed to exec serve script
13 verbose stack Error: [email protected] serve: `vue-cli-service serve`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/juanpablo/.nvm/versions/node/v12.19.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (/Users/juanpablo/.nvm/versions/node/v12.19.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/juanpablo/front-treatments
16 verbose Darwin 19.6.0
17 verbose argv "/Users/juanpablo/.nvm/versions/node/v12.19.0/bin/node" "/Users/juanpablo/.nvm/versions/node/v12.19.0/bin/npm" "run" "serve"
18 verbose node v12.19.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] serve: `vue-cli-service serve`
22 error Exit status 1
23 error Failed at the [email protected] serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Cause analysis:

Webpack version conflict issue in package.json.


Solution:

Delete the webpack and reinstall the previous version
npm uninstall webpack
npm install webpack@^4.0.0 –save-dev

[Solved] Uncaught Error: @electron/remote is disabled for this WebContents

There is an error using the remote module:

Uncaught Error: @electron/remote is disabled for this WebContents. Call require("@electron/remote/main").enable(webContents) to enable it.
    at IpcMainImpl.<anonymous>

 

according to the prompt, you need to add a line: require(“@electron/remote/main”).enable(webContents) in main.js, but if it is added directly, the webcontents is not defined error will be displayed.

You can’t add it directly, webContents should be preceded by the defined variable name, as follows, webContents should be replaced with mainWindow.webContents.

[Solved] npm Error: Error: Cannot find module ‘postcss-loader‘

1. Problem
an error is reported when executing the command NPM run serve:

Error: Cannot find module 'postcss-loader'

2. Solution

The most thorough solution is to uninstall the current nodejs version and install the nodejs version consistent with the module version.

If you don’t want to reinstall nodejs, you can use the following methods:
install module:

npm install postcss-loader

If you continue to report errors:

npm ERR! Could not resolve dependency:
npm ERR! postcss-loader@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^5.0.0" from [email protected]
npm ERR!   node_modules/postcss-loader
npm ERR!     postcss-loader@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Take the – force or — legacy-peer-deps parameter after the command:

npm install postcss-loader --legacy-peer-deps

[Solved] npm Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.

1. NPM error reporting

npm ERR! code 1
npm ERR! path D:\Workspaces\WebstormProjects\shop-ui\buyer\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:\Workspaces\WebstormProjects\shop-ui\buyer\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\Workspaces\WebstormProjects\shop-ui\buyer\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack     at callback (D:\Workspaces\WebstormProjects\shop-ui\buyer\node_modules\graceful-fs\polyfills.js:299:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Workspaces\\WebstormProjects\\shop-ui\\buyer\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:\Workspaces\WebstormProjects\shop-ui\buyer\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Program Files\nodejs\node_cache\_logs\2022-01-28T09_54_16_535Z-debug.log

2. Solution
npm install --global --production windows-build-tools

[Solved] webpack Package Error: TypeError: this.getOptions is not a function style-loader

I used style-loader in the project today, and found an error in packaging: typeerror: this Getoptions is not a function
visual inspection is a version problem. The default version of style-loader is 3.3.1. The reduced version is 2.0.0, and the problem is solved
PS: the webpack version used is 4.28.4

[Solved] NRM Error: error code: ‘err’_INVALID_ARG_Type ‘

Commandnpm install nrm -g to install nrm 1.2.1 error:

[TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
  at validateString (internal/validators.js:122:11)
  at Object.join (path.js:375:7)
  at Object.<anonymous> (C:\Users\liyin\AppData\Roaming\npm\node_modules\nrm\cli.js:17:20)
  at Module._compile (internal/modules/cjs/loader.js:1076:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
  at Module.load (internal/modules/cjs/loader.js:941:32)
  at Function.Module._load (internal/modules/cjs/loader.js:782:14)
  at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
  at internal/main/run_main_module.js:17:47

] {
  code: 'ERR_INVALID_ARG_TYPE'
}

Locate the NRM directory (error line 4)

Open cli.js line 17 is modified to

//const NRMRC = path.join(process.env.HOME, '.nrmrc'); (DELETE)
const NRMRC = path.join(process.env[(process.platform == 'win32') ?'USERPROFILE' : 'HOME'], '.nrmrc');

After saving, reopen the command line to run the NRM LS command normally

C:\Windows\system32>nrm ls
  npm -------- [https://registry.npmjs.org/](https://registry.npmjs.org/)
  yarn ------- [https://registry.yarnpkg.com/](https://registry.yarnpkg.com/)
  cnpm ------- [http://r.cnpmjs.org/](http://r.cnpmjs.org/)
- taobao ----- [https://registry.npm.taobao.org/](https://registry.npm.taobao.org/)
  nj --------- [https://registry.nodejitsu.com/](https://registry.nodejitsu.com/)
  npmMirror -- [https://skimdb.npmjs.com/registry/](https://skimdb.npmjs.com/registry/)
  edunpm ----- [http://registry.enpmjs.org/](http://registry.enpmjs.org/)
  [TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:122:11)
    at Object.join (path.js:375:7)
    at Object.<anonymous> (C:\Users\liyin\AppData\Roaming\npm\node_modules\nrm\cli.js:17:20)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
  ] {
    code: 'ERR_INVALID_ARG_TYPE'
  }

[Solved] npm install sass@~1.32 sass-loader deepmerge -D Install Error

npm install sass@~1.32 sass-loader deepmerge -D install error:

PS E:\dome\automated-test-platform-vue2> npm install sass@~1.32 sass-loader deepmerge -D
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^3.6.0" from the root project
npm ERR!
npm ERR! peer webpack@"^5.0.0" from [email protected]
npm ERR! node_modules/sass-loader
npm ERR!   dev sass-loader@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\shenyf\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\shenyf\AppData\Local\npm-cache\_logs\2022-01-13T03_11_17_119Z-debug.log

Solution:

PS E:\dome\automated-test-platform-vue2> npm install sass@~1.32 sass-loader@7 deepmerge -D

added 7 packages, and audited 1277 packages in 8s
63 packages are looking for funding
  run `npm fund` for details

86 vulnerabilities (2 low, 69 moderate, 15 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.