How to run Jison tests with Node.js? - javascript

Trying to run Jison unit tests, but the command fails.
How do I fix that?
$ git clone git://github.com/zaach/jison.git
Cloning into 'jison'...
remote: Counting objects: 2667, done.
remote: Compressing objects: 100% (1106/1106), done.
remote: Total 2667 (delta 1523), reused 2644 (delta 1501)
Receiving objects: 100% (2667/2667), 731.51 KiB | 129 KiB/s, done.
Resolving deltas: 100% (1523/1523), done.
$ cd jison/
$ make test
node tests/all-tests.js
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'jison'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at new require (module.js:370:17)
at /private/tmp/jison/lib/jison/ebnf.js:43:18
at Object.<anonymous> (/private/tmp/jison/lib/jison/ebnf.js:150:2)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
make: *** [test] Error 1

Add an npm install before make test.

Commands I used to fix the error:
npm install
rm -rf node_modules/jison
ln -s ../ node_modules/jison
npm install downloads all dependencies into ./node_modules, but that includes a copy of jison.

Related

npm Node.js Error: No native build was found M2 MacBook

I got this error on my M2 MacBook, running a project, that worked on my old Intel MacBook. Do you have any idea what the problem is?
I am using bun but npm run dev (node 18) gives me the same error.
The exact same error occurred on other projects.
Package.json dependencies:
"devDependencies": {
"#types/three": "^0.143.1",
"parcel": "^2.7.0"
},
"dependencies": {
"three": "^0.143.0"
}
Console output for bun run dev:
$ parcel src/index.html --open
Error: No native build was found for platform=darwin arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.7.0
loaded from: /Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/lmdb and package: #lmdb/lmdb-darwin-x64
at load.path (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/node-gyp-build-optional-packages/index.js:64:9)
at Object.load [as default] (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/node-gyp-build-optional-packages/index.js:20:30)
at Object.<anonymous> (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/lmdb/dist/index.cjs:47:47)
at Module._compile (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
at Module.load (node:internal/modules/cjs/loader:998:32)
at Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1022:19)
at require (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at _lmdb (/Users/frankmayer/Documents/Git/WorldArchitect/WebGLPreview/node_modules/#parcel/cache/lib/LMDBCache.js:61:39)
Script error "dev" exited with 1 status
Thanks in advance!
You can override a version using the override option in you package.json.
Read more about this option here: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
For me, the solution was to add this to my package.json:
"overrides": {
"lmdb": "2.6.0-alpha6",
"#lmdb/lmdb-darwin-arm64": "2.6.0-alpha6",
"#lmdb/lmdb-darwin-x64": "2.6.0-alpha6",
}
This feature is currently (Aug. 2022) not supported by bun!
Yarn does this using resolutions: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions

Can't open VS Code on Ubuntu

Since today, I can't open vs code on both App shortcut and Terminal.
When I try to run any command related to VS Code like code, code --version and etc. I get this error:
Loading "minimist" failed
Error: EIO: i/o error, read
at Object.readSync (fs.js:592:3)
at Object.p.internalModuleReadJSON (electron/js2c/asar_bundle.js:5:11493)
at Object.read (internal/modules/package_json_reader.js:21:52)
at readPackage (internal/modules/cjs/loader.js:253:36)
at resolveExports (internal/modules/cjs/loader.js:436:15)
at Function.Module._findPath (internal/modules/cjs/loader.js:479:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:921:27)
at Module._load (internal/modules/cjs/loader.js:779:27)
at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
at Module.require (internal/modules/cjs/loader.js:1006:19)
at require (internal/modules/cjs/helpers.js:88:18)
at r (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:101)
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:1723)
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:10695)
at d (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10300)
at Object.errorback (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10421)
at e.triggerErrorback (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:11059)
at /snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:10765
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:1740)
at e.load (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:3:10695)
at d (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10300)
at i._loadModule (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:10430)
at i._resolve (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:6:452)
at i.defineModule (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:5:6142)
at v (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:6:1702)
at g (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:2557)
at Object.<anonymous> (/snap/code/83/usr/share/code/resources/app/out/vs/code/node/cli.js:9:115415)
at Object.<anonymous> (/snap/code/83/usr/share/code/resources/app/out/vs/code/node/cli.js:12:18613)
at e._createAndEvalScript (/snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:2601)
at /snap/code/83/usr/share/code/resources/app/out/vs/loader.js:4:2240
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
errno: -5,
syscall: 'read',
code: 'EIO',
phase: 'loading',
moduleId: 'minimist',
neededBy: [ 'vs/platform/environment/node/argv' ]
}
Here are the modules that depend on it:
[ 'vs/platform/environment/node/argv' ]
Try to install the minimist npm package globally with
npm install -g minimist
Accidentally removed some packages. Solved via reinstalling VS Code.

Deplopyment Error on Vercel: Cannot find module '/vercel/workpath0/.next/server/scripts/build-rss.js'

I have a package.json script like:
{
"export": "next export",
"build": "next build && npm run export && npm run build:rss",
"build:rss": "node ./.next/server/scripts/build-rss.js",
"start": "next start",
}
It has build:rss which points to ./.next/server/scripts/build-rss.js but it cannot find it on Vercel. How do I point it correctly on Vercel? I get the following error & cannot deploy my site:
> node ./.next/server/scripts/build-rss.js
15:14:05.786 internal/modules/cjs/loader.js:968
15:14:05.786 throw err;
15:14:05.786 ^
15:14:05.786 Error: Cannot find module '/vercel/workpath0/.next/server/scripts/build-rss.js'
15:14:05.786 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
15:14:05.786 at Function.Module._load (internal/modules/cjs/loader.js:841:27)
15:14:05.786 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
15:14:05.786 at internal/main/run_main_module.js:17:47 {
I tried asking Vercel support but they said:
I recommend doing something like this → https://github.com/pacocoursey/paco/blob/master/package.json. I'm afraid we do not provide complete code-level support for users on the Hobby plan.
Not sure the link is relevant :(
I had to change server to serverless to make it work on Vercel :)

node_modules error: missing module postcss, when is present in node_modules/.bin

I'm trying to run a package.json script (with yarn) however it seems to fail due to a missing module. However when checking node modules it seems the relevant module is there, so I'm not clear how to resolve the error.
~/P/j/tw-tutorial ❯❯❯ yarn build:css
yarn run v1.22.4
$ postcss src/css/tailwind.css -o src/css/main.css
internal/modules/cjs/loader.js:955
throw err;
^
Error: Cannot find module '../'
Require stack:
- /Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
at Function.Module._load (internal/modules/cjs/loader.js:835:27)
at Module.require (internal/modules/cjs/loader.js:1012:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss:3:1)
at Module._compile (internal/modules/cjs/loader.js:1123:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:972:32)
at Function.Module._load (internal/modules/cjs/loader.js:872:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~/P/j/tw-tutorial ❯❯❯ postcss src/css/tailwind.css -o src/css/main.css
fish: Unknown command: postcss
~/P/j/tw-tutorial ❯❯❯ npx postcss src/css/tailwind.css -o src/css/main.css
Cannot find module '../'
Require stack:
- /Users/yunti/Projects/js/tw-tutorial/node_modules/.bin/postcss
~/P/j/tw-tutorial ❯❯❯ ll ./node_modules/.bin | grep postcss
-rwxr-xr-x 1 yunti staff 36B 24 Apr 10:20 postcss
update looks like the error is coming from postcss (not because postcss can't be found) as
postcss.config.js
module.exports = {
plugins:[
require('tailwindcss'),
require('autoprefixer'),
process.env.NODE_ENV === 'production' && require('#fullhuman/postcss-purgecss')({
content: [
'.src/**/*.js',
'.src/**/*.jsx',
'./public/index.html',
],
defaultExtractor: content=> content.match(/[A-Za-z0-9-_:/]+/g) || []
})
],
};

I'm getting Cannot find module 'protractor-jasmine2-html-reporter'

i tried to generate reports by using "'protractor-jasmine2-html-reporter'", but i'm getting module not found exception with error code 5..i tried the somany solutions gathered from stack overflow, but it is not worked. can somebody please help me in this.
Config.js
var Jasmine2HtmlReporter=require('protractor-jasmine2-html-reporter');
exports.config = {
directConnect : true,
capabilities:{
'browserName':'chrome'
},
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['ProtractorTest/PageObjectMain.js'],
jasmineNodeOpts:{
defaultTimeoutInterval : 30000
},
onPreapre:function(){
jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
savePath:"./test-results/report"
}));
},
}
Error log
[14:54:53] E/configParser - Error code: 105
[14:54:53] E/configParser - Error message: failed loading configuration file ReportConfig.js
[14:54:53] E/configParser - Error: Cannot find module 'protractor-jasmine2-html-reporter'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (H:\workspace\Protractor_tutorials\ReportConfig.js:1:88)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
and my 'Package.Json' not have any details about the report files.. so if that is the problem, please help me to how to configure those in json file.
There are few things you have to make sure while using Protractor Reporters
1.in my case, in the time creating variable for reporter instead of directly passing Reporter name try to pass the full path of Reporter module.. may this will work
Eg :
var Jasmine2HtmlReporter=require('C:/......./npm-modules/protractor-jasmine2-html-reporter');
2.make sure you running the Correct Configuration file having .js extension.
Installing without save-devworked for me .
Installed globally
npm install -g protractor-jasmine2-html-reporter
Run below command to link protractor and jasmine2-html-reporter to aovid report not generating issue. Please see Girish Sortur's answer in How to create Protractor reports with Jasmine2
npm link protractor-jasmine2-html-reporter
Also add this import with path to exact node module to avoid the error in windows 10
var Jasmine2HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');
Full conifg,js that worked for me in windows 10 as per below.
//protractor jasminreporterconfig.js
//Add this import with path to exact node module to avoid the error
var Jasmine2HtmlReporter = require('C:/Users/sam/AppData/Roaming/npm/node_modules/protractor-jasmine2-html-reporter');
exports.config = {
framework: 'jasmine',
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--start-maximized" ]
}
},
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
takeScreenshots: true,// By default this is enabled Default is true
takeScreenshotsOnlyOnFailures: false, // Default is false (So screenshots are always generated)
cleanDestination: true, // if false, will not delete the reports or screenshots before each test run.Default is true
showPassed: true,//default is true This option, if false, will show only failures.
fileName: 'MyRepoDemo', //We can give a prefered file name .
savePath: 'myproreports',//Reports location it will automatically generated
screenshotsFolder: 'screenshotsloc' //Screenshot location it will create a folder inside myproreports
})
);
},
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['src/com/sam/scriptjs/nonangularstackscript.js']
}
It looks like You haven't installed protractor-jasmine2-html-reporter
Go to folder where packages are installed (node_modules folder) and run:
npm install protractor-jasmine2-html-reporter
Try to check where the node_modules directory is present by running npm audit and which npm commands. The main thing is path where node_modules is installed should be traced and the new module like npm install protractor-jasmine2-html-reporter can be installed in that path

Categories