I got this error while installing the react app. Perviously, it was working well but, now it started to show this error. How to fix it?
internal/modules/cjs/loader.js:614
throw e;
^
Error: No valid exports main found for 'D:\Programming\react\stores\node_modules\is-promise'
at resolveExportsTarget (internal/modules/cjs/loader.js:611:9)
at applyExports (internal/modules/cjs/loader.js:492:14)
at resolveExports (internal/modules/cjs/loader.js:541:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:643:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:941:27)
at Function.Module._load (internal/modules/cjs/loader.js:847:27)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at Object.<anonymous> (D:\Programming\react\stores\node_modules\run-async\index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1121:30) {
code: 'MODULE_NOT_FOUND'
}
Aborting installation.
node has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Done.
i think this issue is related to is-promise issue
https://github.com/then/is-promise/issues/14#issue-606798951
they are working for fixing the bug.
Related
When I try to run this React app -->(https://github.com/mehdish9197/reactapp),
I get this error -->
node:internal/modules/cjs/loader:544
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in F:\New folder (6)\django mern stack electronjs projects\New folder (3)\DRF-Ecommerce-Platform-master\client\node_modules\postcss-safe-parser\node_modules\postcss\package.json
at new NodeError (node:internal/errors:393:5)
at exportsNotFound (node:internal/modules/esm/resolve:295:10)
at packageExportsResolve (node:internal/modules/esm/resolve:631:9)
at resolveExports (node:internal/modules/cjs/loader:538:36)
at Module._findPath (node:internal/modules/cjs/loader:607:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1025:27)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (F:\New folder (6)\django mern stack electronjs projects\New folder (3)\DRF-Ecommerce-Platform-master\client\node_modules\postcss-safe-parser\lib\safe-parser.js:1:17) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
I installed node modules with the npm install command And when I hit npm start I get this error
I am using node version 18.12.1...
Can anyone solve my problem?
tnx in advance
I started with NextJS, before that I used React a lot.
I run the app on docker (node:18-alpine) if it makes any difference.
I have API thing that I wrote before and published as NPM module. Now I install it with yarn add sjiamnocna/renette-api, it's ok, I can use it with react.
I have file "next-app/utils/API/initapi.ts" containing
import CAPI from "renette-api"
const API = new CAPI()
API.authenticateWithName('abcdef')
API.authorizeWithKey('12345')
export default API
It gives me SyntaxError: Unexpected token 'export'
Nothing I found worked so far, any idea?
EDIT1:
Suppose it fails during the runtime (running yarn dev) because it's successfully built and served for development. The CMD tells the same thing as the browser
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1026:15)
at Module._compile (node:internal/modules/cjs/loader:1061:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.renette-api (/home/sjiamnocna/Documents/wrk/docker_test/nginxphppg/next-app/.next/server/pages/index.js:52:18)
at __webpack_require__ (/home/sjiamnocna/Documents/wrk/docker_test/nginxphppg/next-app/.next/server/webpack-runtime.js:33:42) {
page: '/'
}
I have the file in directory next to the pages directory, couldn't that cause anything?
Ok, the solution is "workaround".
I changed the target of my package to ES5, now it exports the old style as NextJS expects it. BUT, if you guys have some trick to make the ES6 imports work, tell me
// before
export default MyClass
// now
module.exports = default
Have a nice day
I am trying to write a simple UI client app which will read the smart contract to fetch some data. However I am stuck in getting the build artifact inside the /src folder. During deployment of the smart contract (migrate) on a local Truffle network, I noticed the build artifact is not getting copied over to src folder. However I have mentioned it in the truffle config file.
truffle config content
const path = require('path');
contracts_build_directory: path.join(__dirname + 'client-app/src/contracts'),
App.js - I have already defined an import statement
import PetShop from './contracts/PetShop.json';
The react app was created using the npm module create-react-app.
But during the deploy, the contract artifact is not copied over to /src - hence it gives could not find module error.
Any help
Thanks
PS C:\Users\HP\new-react> node src/dare.js
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module './build/contracts/so.json'
Require stack:
- C:\Users\HP\new-react\src\dare.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\HP\new-react\src\dare.js:3:20)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\HP\\new-react\\src\\dare.js' ]
}
The answer to this is very simple, make sure you point your react file to the right path.
enter image description here
Before I referenced the path correctly, it showed an error.
const MyContract = require('./build/contracts/so.json');
To correct the error do this:
const MyContract = require('../build/contracts/so.json');
I'm upgrading packages in my Next app, including Next 11 and React v17. I tried everything I could find online but still getting this error.
Here's full console output.
Error: Cannot find module 'react/jsx-dev-runtime'
Require stack:
- /Users/wk/repo/.next/server/pages/_document.js
- /Users/wk/repo/guest/node_modules/next/dist/next-server/server/require.js
- /Users/wk/repo/guest/node_modules/next/dist/next-server/server/load-components.js
- /Users/wk/repo/guest/node_modules/next/dist/next-server/server/api-utils.js
- /Users/wk/repo/guest/node_modules/next/dist/next-server/server/next-server.js
- /Users/wk/repo/guest/node_modules/next/dist/server/next.js
- /Users/wk/repo/guest/node_modules/next/dist/server/lib/start-server.js
- /Users/wk/repo/guest/node_modules/next/dist/cli/next-dev.js
- /Users/wk/repo/guest/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.mod._resolveFilename (/Users/wk/repo/guest/node_modules/next/dist/build/webpack/require-hook.js:4:1855)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.react/jsx-dev-runtime (/Users/wk/repo/.next/server/pages/_document.js:227:18)
at __webpack_require__ (/Users/wk/repo/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///./src/pages/_document.js:5:79)
at Object../src/pages/_document.js (/Users/wk/repo/.next/server/pages/_document.js:66:1)
at __webpack_require__ (/Users/wk/repo/.next/server/webpack-runtime.js:33:42) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/wk/repo/.next/server/pages/_document.js',
'/Users/wk/repo/guest/node_modules/next/dist/next-server/server/require.js',
'/Users/wk/repo/guest/node_modules/next/dist/next-server/server/load-components.js',
'/Users/wk/repo/guest/node_modules/next/dist/next-server/server/api-utils.js',
'/Users/wk/repo/guest/node_modules/next/dist/next-server/server/next-server.js',
'/Users/wk/repo/guest/node_modules/next/dist/server/next.js',
'/Users/wk/repo/guest/node_modules/next/dist/server/lib/start-server.js',
'/Users/wk/repo/guest/node_modules/next/dist/cli/next-dev.js',
'/Users/wk/repo/guest/node_modules/next/dist/bin/next'
]
}
Would appreciate any suggestions. Thanks!
EDIT
I already tried removing node_modules, yarn.lock file etc.
Updating react and react-dom didn't work?
I had the same problem after updating next, I removed the .next folder before updating react and react-dom and after that it worked. I am not sure that removing the folder is needed.
I updated both react and react-dom to 17.0.2.
I also ran into this issue, and simply removing the webpack folder from .next solved the issue.
I started programming a Discord bot with javascript, but ran into an error that I don't know how to fix.
Please help me =)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
} ```
You are trying to run a file which dosent exist. Even i had this error and in my case i was trying to run
node app.js
but I had named my file as index.js, so I had to run.
node index.js
I had a big facepalm after that :P