"npm run dev" command is not running. In terminal it giving an error like "[ERR_PACKAGE_PATH_NOT_EXPORTED]".
How I will export that ERR_PACKAGE_PATH.
I have tried to solve it but always facing the same issue. so what is the actual cause behind it.
Here is my error message.
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in D:\06-onwards-to-a-bigger-project-starting-project\node_modules\postcss\package.json
at new NodeError (node:internal/errors:399:5)
at exportsNotFound (node:internal/modules/esm/resolve:266:10)
at packageExportsResolve (node:internal/modules/esm/resolve:602:9)
at resolveExports (node:internal/modules/cjs/loader:550:36)
at Module._findPath (node:internal/modules/cjs/loader:619:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1046:27)
at Module._load (node:internal/modules/cjs/loader:905:27)
at Module.require (node:internal/modules/cjs/loader:1127:19)
at require (node:internal/modules/helpers:112:18)
at 552 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11590)
at __nccwpck_require__ (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at 270 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:400)
:1:11735)
at 327 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:260)
at __nccwpck_require__ (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at 845 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:3733) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
PS D:\06-onwards-to-a-bigger-project-starting-project> npm run build
> nextjs#1. ...
node:internal/errors:490
ErrorCaptureStackTrace(err);
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in D:\06-onwards-to-a-bigger-project-starting-project\node_modules\postcss\package.json
at new NodeError (node:internal/errors:399:5)
at exportsNotFound (node:internal/modules/esm/resolve:266:10)
at packageExportsResolve (node:internal/modules/esm/resolve:602:9)
at resolveExports (node:internal/modules/cjs/loader:550:36)
at Module._findPath (node:internal/modules/cjs/loader:619:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1046:27)
at Module._load (node:internal/modules/cjs/loader:905:27)
at Module.require (node:internal/modules/cjs/loader:1127:19)
at require (node:internal/modules/helpers:112:18)
at 552 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11590)
at __nccwpck_require__ (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at 270 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:400)
at __nccwpck_require__ (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at 327 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:260)
at __nccwpck_require__ (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:11735)
at 845 (D:\06-onwards-to-a-bigger-project-starting-project\node_modules\next\dist\compiled\postcss-scss\scss-syntax.js:1:3733) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Related
I am following the documentation at https://jestjs.io/docs/getting-started
I have a directory structure like...
learnjest/sum.js
learnjest/sum.test.js
learnjest/package.json
learnjest/package-lock.json
learnjest/node_modules
My sum.js, sum.test.js and package.json are all exact copies of the code in the "Getting Started" example.
sum.js:
function sum(a, b) {
return a + b;
}
module.exports = sum;
sum.test.js:
const sum = require('./sum');
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
package.json:
{
"scripts": {
"test": "jest"
}
}
When I run npm test, I see...
> # test /path/to/learnjest
> jest
/path/to/learnjest/node_modules/jest/node_modules/jest-cli/build/cli/index.js:161
if (error?.stack) {
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/path/to/learnjest/node_modules/jest/node_modules/jest-cli/build/index.js:13:12)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
npm ERR! Test failed. See above for more details.
__drush_ps1: command not found
__git_ps1: command not found
The problem can occur if you are using an older version of Node.js. For example, I had the same problem with version 12. After I upgraded Node.js version to 19.2 the error was fixed.
Here's my code for election.js:
import { isMainThread } from "worker_threads";
import { AssertionError } from "assert";
var Election = artifacts.require("./Election.sol");
contract("Election",function(accounts){
it("initializes with two candidates",function(){
return Election.deployed().then(function(instance){
return instance.candidatesCount();
}).then(function(count){
AssertionError.equal(count,2);
});
});
});
When I am trying to test it using:
truffle test
The following error is displaying at the terminal:
Using network 'development'.
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
/home/shreyas/election/test/election.js:1 import { isMainThread } from "worker_threads";
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:718:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at /usr/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/usr/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/usr/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:576:10)
at /usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/test.js:138:1
at new Promise (<anonymous>)
at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/test.js:137:1)
at processTicksAndRejections (internal/process/task_queues.js:89:5) Truffle v5.1.8 (core: 5.1.8) Node v12.3.1
Please help me in dealing with this error.
Thanks in advance.
I am trying to use the generateKeyPairSync() function of the crypto module of node.js. But am getting a typerError saying that there is no such function.
Its strange because another function of the same module createCipher() works perfectly!
Here is the sample code:
import * as cryp from 'crypto';
export function generate_keys() {
console.log('hey there!');
const keyPair = cryp.generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: 'aes-256-cbc',
passphrase: 'top secret'
}
});
console.log(keyPair);
}
function encrypt(data: string) {
let cipher = cryp.createCipher('aes-256-ecb', 'pass');
cipher.update(data, 'utf8');
return cipher.final('hex');
}
// This is working
console.log(encrypt('asa'));
// Getting error - 'generateKeyPairSync is not a function'
generate_keys();
This is the complete console output:
[Running] ts-node "d:\projects\myProject\src\ply.ts"
4eb35bc94bd4d17fad4857b17558b2ad
hey there!
d:\projects\myProject\src\ply.ts:5
const keyPair = cryp.generateKeyPairSync('rsa', {
^
TypeError: cryp.generateKeyPairSync is not a function
at generate_keys (d:\projects\myProject\src\ply.ts:5:24)
at Object.<anonymous> (d:\projects\myProject\src\ply.ts:33:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Module.m._compile (C:\Users\anmolsingh.jaggi\AppData\Local\Yarn\Data\global\node_modules\ts-node\src\index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\anmolsingh.jaggi\AppData\Local\Yarn\Data\global\node_modules\ts-node\src\index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
[Done] exited with code=1 in 2.097 seconds
From the docs:
Added in: v10.12.0
I guess you are running an earlier version of node
I am trying out an electron app which should point to our website, so I am trying one of the tutorials.. Unfortunately, when I start the app, I get the following error :
Error log :
akshay#akshay-mint-desktop ~/electron_tutorial_one $ npm start
> electron_tutorial_one#1.0.0 start /home/akshay/electron_tutorial_one
> electron .
App threw an error during load
Error: Cannot find module 'app'
at Module._resolveFilename (module.js:455:15)
at Function.Module._resolveFilename (/home/akshay/electron_tutorial_one/node_modules/electron-prebuilt/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/akshay/electron_tutorial_one/index.js:2:11)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'app'
at Module._resolveFilename (module.js:455:15)
at Function.Module._resolveFilename (/home/akshay/electron_tutorial_one/node_modules/electron-prebuilt/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/akshay/electron_tutorial_one/index.js:2:11)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
^Cakshay#akshay-mint-desktop ~/electron_tutorial_one $
index.js :
// Require the libraries used in the app
var app = require('app'),
BrowserWindow = require('browser-window');
require('crash-reporter').start();
var mainWindow = null;
// Kill the app when all windows are closed
app.on('mainWindow-all-closed', function() {
if (process.platform != 'darwin')
app.quit();
});
app.on('ready', function() {
// Create the main window for the app
mainWindow = new BrowserWindow({
"min-width" : 800,
"min-height" : 600,
fullscreen : true,
resizable : true,
"use-content-size" : true
});
// Load in our content
mainWindow.loadUrl('file://' + __dirname + '/index.html');
// This is required for now due to https://github.com/atom/electron/issues/1117
mainWindow.openDevTools();
mainWindow.closeDevTools();
// Ensure that garbage collection occurs when the window is closed
mainWindow.on('closed', function() {
mainWindow = null;
});
});
package.json :
{
"name": "electron_tutorial_one",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-prebuilt": "^1.4.13"
}
}
Instead of
// Require the libraries used in the app
var app = require('app'), BrowserWindow = require('browser-window');
you should use
const { app, BrowserWindow } = require('electron')
You've used a really old example. Electron modules are collected under 'electron' in 0.35.0 more then two years ago ;)
From release notes:
Add electron module which includes all public APIs.
You'd better use tutorials from electron docs:
https://www.electronjs.org/docs/tutorial/quick-start
https://github.com/electron/electron-quick-start
I have a Phoenix app and am trying to get Mocha wired up for javascript unit tests. I want to test module 'Two', that imports module 'One' but I can't figure out how to configure Mocha to find module one.
Here is the test code:
web/static/js/one.js
export var One = 1;
web/static/js/two.js
import {One} from "web/static/js/one";
export var Two = function () {return One + One;}
> test/js/two_test.js
import assert from 'assert';
import {Two} from "../../web/static/js/two";
describe('Two()', function() {
it('returns value 2', function () {
assert.equal(2, Two());
});
});
Here is the output when I run npm test
home:~/elixir/optitrue$ npm test
> # test /home/jon/elixir/optitrue
> mocha --compilers js:babel-register test/js/**/*.js
module.js:457
throw err;
^
Error: Cannot find module 'web/static/js/one'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (two.js:1:1)
at Module._compile (module.js:556:32)
at loader (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:148:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:158:7)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (two_test.js:2:1)
at Module._compile (module.js:556:32)
at loader (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:148:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:158:7)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at /home/jon/elixir/optitrue/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/home/jon/elixir/optitrue/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/home/jon/elixir/optitrue/node_modules/mocha/lib/mocha.js:485:10)
at Object.<anonymous> (/home/jon/elixir/optitrue/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
brunch.config
exports.config = {
// See http://brunch.io/#documentation for docs.
files: {
javascripts: {
joinTo: "js/app.js"
},
stylesheets: {
joinTo: "css/app.css"
},
templates: {
joinTo: "js/app.js"
}
},
conventions: {
assets: /^(web\/static\/assets)/
},
// Phoenix paths configuration
paths: {
watched: [
"web/static",
"test/static"
],
// Where to compile files to
public: "priv/static"
},
// Configure your plugins
plugins: {
babel: {
// Do not use ES6 compiler in vendor code
ignore: [/web\/static\/vendor/]
}
},
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"]
}
},
npm: {
enabled: true,
whitelist: ["phoenix", "phoenix_html"]
}
};
The error is quite clear:
Error: Cannot find module 'web/static/js/one'
Meaning the path you provided doesn't work, try using a relative paths:
import {One} from "./one";