I'm getting a weird (ERRCODE 243) error when installing a 3rd party js package using Rush.js by running `rush add --package <package>` - npm

my team is migrating to rush and I had a problem while setting it up: I'm getting a weird error when trying to add any 3rd party lib (let's say react) to package.json using rush add --package react (for example). The error log:
Found configuration in /home/ivan/dev/JS/eisbuk/rush.json
Rush Multi-Project Build Tool 5.66.2 - https://rushjs.io
Node.js version is 14.19.0 (LTS)
Found configuration in /home/ivan/dev/JS/eisbuk/rush.json
Starting "rush add"
Determining new version for dependency: react
No version selector was specified, so the version will be determined automatically.
Trying to acquire lock for pnpm-6.32.3
Acquired lock for pnpm-6.32.3
Found pnpm version 6.32.3 in /home/ivan/.rush/node-v14.19.0/pnpm-6.32.3
Symlinking "/home/ivan/dev/JS/eisbuk/common/temp/pnpm-local" --> "/home/ivan/.rush/node-v14.19.0/pnpm-6.32.3"
The "ensureConsistentVersions" policy is NOT active, so we will assign the latest version.
Querying NPM registry for latest version of "react"...
ERROR: The command failed with exit code 243
I tried to find a similar problem report related to rush and looked up the 243 error with npm, both to no avail. I'm using pnpm, however, the error persists with npm and yarn all the same (with yarn it's exit code 1, everything else is the same).
Here's my .npmrc (a default really):
registry=https://registry.npmjs.org/
always-auth=false
Interestingly enough, if I manually add a dependency to package.json and run rush update, the update goes well and the dep is added to node_modules and shrinkwrap (so it shouldn't be an npm registry problem).
Here's my rush.json:
{
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json",
"rushVersion": "5.66.2",
"pnpmVersion": "6.32.3",
"pnpmOptions": {
"preventManualShrinkwrapChanges": true,
"useWorkspaces": true
},
"nodeSupportedVersionRange": ">=12.13.0 <13.0.0 || >=14.15.0 <15.0.0 || >=16.13.0 <17.0.0",
"gitPolicy": {},
"repository": {},
"eventHooks": {
"preRushInstall": [],
"postRushInstall": [],
"preRushBuild": [],
"postRushBuild": []
},
"variants": [],
"projects": [
/** ...other projects */
{
"packageName": "#eisbuk/functions",
"projectFolder": "packages/functions"
}
/** ...other projects */
]
}
The entire repo can be found at: https://github.com/eisbuk/EisBuk/tree/feature/rush

Solved!
In the end, I've managed to pinpoint it to the node version. I was using v14.19.0 and bumping to v16.14.2 solved it. I don't know if it's a known incompatibility, but here it is.

Related

Changing the versions of the compiler

Maybe someone faced such a problem? I tried to change versions of the compiler, after changing 1 time it accumulates without errors, it crashes again with the same error. Tried 0.64.0, 0.63.0, 0.62.0, 0.61.0, On the last one instead of "[ERROR] undefined" returned "[ERROR] Error: 1". What is the problem?
At the same time, everything passes through ""everdev sol compile"" norms. I don’t really want to switch from locklift, but got stuck due to a mistake.
Thanks!
npx locklift init --path amazing-everscale-project
cd amazing-everscale-project
npm install --save-dev everdev
npx everdev sol set --compiler 0.64.0 --linker 0.18.4
Update locklift.config.ts
const config: LockliftConfig = {
compiler: {
path: "~/.everdev/solidity/solc",
},
linker: {
lib: "~/.everdev/solidity/stdlib_sol.tvm",
path: "~/.everdev/solidity/tvm_linker",
},
...
build
npx locklift build

"Cannot read property 'upgrade' of undefined" when starting vue application

I have a project that's been running perfectly for a few months now, able to run npm run serve with no problem. I have to terminate and run the command again whenever I switch networks, but that has never been a problem and the server could always start again.
Until now - no matter what I do I can't get the server to start. I get this error:
npm run serve
> xbs#0.6.2 serve D:\workspace\[PROJECT]
> vue-cli-service serve
INFO Starting development server...
10% building 1/1 modules 0 active ERROR TypeError: Cannot read property 'upgrade' of undefined
TypeError: Cannot read property 'upgrade' of undefined
at Server.<anonymous> (D:\workspace\[PROJECT]\node_modules\webpack-dev-server\lib\Server.js:667:47)
at Array.forEach (<anonymous>)
at new Server (D:\workspace\[PROJECT]\node_modules\webpack-dev-server\lib\Server.js:666:22)
at serve (D:\workspace\[PROJECT]\node_modules\#vue\cli-service\lib\commands\serve.js:137:20)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
The last time I got this message was when I forgot to set the .env files, but this is a previously working copy with all necessary files set, and no changes since the last working run.
I've even tried pulling a fresh copy of the repo, running npm i and setting all env files but it still fails.
npm run lint and npm run build can still work, only npm run serve.
Am I missing anything?
The problem was again with the .env files. My vue.config.js was trying to access a previously set environment variable that had since been removed.
Only strange thing was that there weren't any problems up til now?
I guess your devServer.proxy.target is empty!
You could set this configuration
For me it was that I forgot to create (or copy from another PC) the .env file after clone and try to run my project on another PC.
I also had this problem.
I used in the project process to get the backend address(for example):
devServer: {
proxy: {
'/api/back/*': {
target: process.env.VUE_APP_BACKEND_URL,
pathRewrite: {
'/api/back': '/api/back',
},
},
},
},
But there was no .evn file.
Just create .env file:
VUE_APP_BACKEND_URL= 0.0.0.0:2222 #example
Didn't notice the answer #Sergey.
I declared this environment variable in .env.dev, but the local build failed, and the same project ran without problems, so I created a new .env file and declared it in it
proxy: {
'/api': {
target: process.env.VUE_APP_PROXY,
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
}

Command to check if there is any range versions in the dependencies section of the package.json

Basically I want CI to fail if the dependencies section of the package.json contains any range operator. devDependencies could contain anything thought. Some CLI command would be perfect. Any suggestions?
Short answer: Unfortunately, there is no existing built-in npm command/feature to achieve this. However, you can utilize your own custom nodejs script. The nodejs script can then be invoked via a command if you define it in the scripts section of your package.json.
The following describes how to achieve this.
Solution
check-deps.js
Create a nodejs script as follows. Let's name the script check-deps.js and save it somewhere in your project directory.
const isSemverRange = require('is-semver-range');
const pkgPath = './path/to/your/package.json';
const pkgData = require(pkgPath);
function hasSemverRange({ dependencies = {}}) {
return Object.values(dependencies).some(semver => isSemverRange(semver));
}
if (hasSemverRange(pkgData)) {
console.log(`Semver range(s) found in dependencies section of ${pkgPath}`);
process.exit(1);
}
Explanation of check-deps.js:
Firstly we require the is-semver-range package, which we'll use to help check for any semver ranges. To install this package; cd to your project directory and run the following command:
npm i -D is-semver-range
We then define a path to the package.json file (i.e. the file we want to check), and subsequently we require its contents.
const pkgPath = './path/to/your/package.json'; // <-- Redefine path.
const pkgData = require(pkgPath);
Note: you'll need to redefine your path to package.json as necessary.
The hasSemverRange function parameter definition utilizes object destructuring to unpack the dependencies object, and assigns an empty object as a default value to avoid errors occurring if the dependencies section is missing from package.json.
In the function body we pass in the dependencies object to the Object.values method, and utilize the Array.some() method to test whether at least one of the values is a semver range.
This function returns true if the value of any property/key of the dependencies object is as a semver range, otherwise it returns false.
Finally, in the if statement condition we invoke the hasSemverRange function, passing to it the parsed contents on package.json. If the condition is truthy we log an error message to the console, and exit the script with a non-zero exit code, i.e. process.exit(1).
package.json
In the scripts section of your package.json define a script as follows. Let's name the script check-deps:
"scripts": {
"check-deps": "node path/to/check-deps.js",
...
}
Note: you'll need to redefine your path to check-deps.js as necessary.
Running the npm script
Run the following command via your CLI to invoke the check-deps script:
npm run check-deps
If the value of any property defined in the dependencies section of your package.json is a semver range you'll see something like the following error logged to your console:
Semver range(s) found in dependencies section of ./path/to/package.json
Integrating the check with your CI tool.
It's unclear from your question which CI tool you're using. However, typically CI tools provide a feature which allows you to invoke an npm script.
For example, if your utilizing Travis CI you can define the script to run in your .travis.yml file as follows:
.travis.yml
script:
- npm check-deps
Additional Note:
You could also invoke the npm check-deps script via an existing test script which you may have already defined in your package.json by utilizing the && operator. For instance:
"scripts": {
"check-deps": "node path/to/check-deps.js",
"test": "yourCurrentTestcommands && npm run check-deps"
...
}
Note: In the test script above the yourCurrentTestcommands part should be replaced with any commands that you may currently be running.

Bigcommerce Stencil Start Error

I recently installed stencil on my local machine, and went through the stencil init process. However when I run stencil start I am getting the following error:
{ [Error: ../../node_modules/#bigcommerce/citadel/dist/tools/toolkit.scss doesn't exist!]
formatted: 'Error: ../../node_modules/#bigcommerce/citadel/dist/tools/toolkit.scss doesn\'t exist!\n on line 13 of stdin\n>> #import "../../node_modules/#bigcommerce/citadel/dist/tools/toolkit"; // 1\n --------^\n',
message: '../../node_modules/#bigcommerce/citadel/dist/tools/toolkit.scss doesn\'t exist!',
column: 9,
line: 13,
file: 'stdin',
status: 1 }
{ [Error: ../../node_modules/#bigcommerce/citadel/dist/tools/toolkit.scss doesn't exist!]
formatted: 'Error: ../../node_modules/#bigcommerce/citadel/dist/tools/toolkit.scss doesn\'t exist!\n on line 13 of stdin\n>> #import "../../node_modules/#bigcommerce/citadel/dist/tools/toolkit"; // 1\n --------^\n',
message: '../../node_modules/#bigcommerce/citadel/dist/tools/toolkit.scss doesn\'t exist!',
column: 9,
line: 13,
file: 'stdin',
status: 1 }
I know this question was asked previously last year, but going with the provided answer and doing a fresh stencil install isn't working for me. There seems to be a problem with bigcommerce's cli as many of the css files it is trying to import are not being found. Has anyone worked through this problem and found a solution?
First off I would delete your stencil configuration and re-run:
stencil init
If that doesn't work try to move to the root folder that holds your stencil files and run:
npm install
What this will do is install any npm packages that may not have been installed. It could be why the Stencil CLI can't find them.
Did you tried to reinstall Latest version of Nodejs?

Is there a way to get the data that is returned by `npm view <package name>`, perhaps by an official api?

The data that is returned is in JSON format:
$ npm view react-router
{ name: 'react-router',
description: 'Declarative routing for React',
'dist-tags': { latest: '4.0.0', next: '4.0.0-beta.8', previous: '3.0.3' },
versions:
[ '0.0.0',
'0.0.1',
'0.4.0',
'0.4.1',
'0.4.2',
'0.5.0',
'0.5.1',
// ...
Is there an official api for this info? I saw one npm module called npm-web-api but don't see an official published API.
That information comes from the npm registry API (format); your example can be found at https://registry.npmjs.com/react-router.