Closed stuyy closed 4 years ago
I am running into the same issue. Even when I run nest start --watch
.
I am running into the same issue. Even when I run
nest start --watch
.
This issue also happens when I'm running any of the scripts, like npm run start or start:dev. I fixed it by going inside the is-promise package, and removed the "type: module" property-value inside package.json like it said in there. But I did not have this issue before 3 days ago, strange suddenly it's an issue?
I just checked my other nest project I had created 3 days ago and I did not see the "type: module" property-value in the npm package "is-promise"'s package.json file, so I don't know what caused it to add that property this time.
Thanks @ansonfoong did that and it works for me too.
Problem only happens to me on node v12.16.2
, but it does not happen on v10.20.1
.
A new version of is-promise was released 2 hours ago. type: module
was added in this commit.
If you're using Yarn, adding this to your package.json:
{
"dependencies": {},
"devDependencies": {},
"resolutions": {
"is-promise": "2.1.0"
}
}
should fix the issue. I am not sure if there is a npm equivalent of "resolutions".
Oops, I think that new release of is-promise broke the CLI.
I created a new user on my machine and can't get the nest new
command working.
internal/modules/cjs/loader.js:584
if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e;
^
Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /usr/local/lib/node_modules/@nestjs/cli/node_modules/is-promise/package.json
at resolveExportsTarget (internal/modules/cjs/loader.js:542:13)
at resolveExportsTarget (internal/modules/cjs/loader.js:581:20)
at applyExports (internal/modules/cjs/loader.js:455:14)
at resolveExports (internal/modules/cjs/loader.js:508:23)
at Function.Module._findPath (internal/modules/cjs/loader.js:632:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1001:27)
at Function.Module._load (internal/modules/cjs/loader.js:884:27)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/usr/local/lib/node_modules/@nestjs/cli/node_modules/run-async/index.js:3:17) {
code: 'ERR_INVALID_PACKAGE_TARGET'
}
This workaround fixed above issue on my machine:
diff --git a/package-lock.json b/package-lock.json
index 592f371..cb4cdb1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5293,9 +5293,9 @@
}
},
"is-promise": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.0.tgz",
- "integrity": "sha512-N/4ZxZGjDLAWJQNtcq1/5AOiWTAAhDwnjlaGPaC2+p3pQ+Ka2Dl/EL29DppuoiZ8Xr1/p/9ywBGGzHRPoWKfGA=="
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
+ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
},
"is-regex": {
"version": "1.0.5",
Issue fixed by is-promise lib author commit: https://github.com/then/is-promise/commit/68d3d6871806162772b33e9629908ded6c8bf0b1
Release 2.2.2
npm uninstall -g @nestjs/cli
npm install -g @nestjs/cli
Should fix the problem, it works for me now.
Confirmed to be working again. This issue can be closed.
I did everything in this ticket to no avail;
cannot load nest models anymore
> nx run api-typegoose:serve
chunk (runtime: main) main.js (main) 45.5 KiB (javascript) 937 bytes (runtime) [entry] [rendered]
webpack compiled successfully (19b9838b05893a4a)
Debugger listening on ws://localhost:9229/5c219b58-7461-47ca-8f83-810bf260b673
Debugger listening on ws://localhost:9229/5c219b58-7461-47ca-8f83-810bf260b673
For help, see: https://nodejs.org/en/docs/inspector
Issues checking in progress...
file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/webpack:/starter/external commonjs "@nestjs/core":1
module.exports = require("@nestjs/core");
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/Users/meanstack02/new/starter/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at Object.@nestjs/core (file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/webpack:/starter/external commonjs "@nestjs/core":1:1)
at __webpack_require__ (file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/webpack:/starter/webpack/bootstrap:19:1)
at file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/main.js:1702:70
at file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/main.js:1777:3
at file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/main.js:1782:12
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at ESMLoader.import (node:internal/modules/esm/loader:281:24)
at loadESM (node:internal/process/esm_loader:88:5)
at handleMainPromise (node:internal/modules/run_main:65:12)
No issues found
the ecosystem has imposed this now on all
can we get some assist?
can nestjs hold pace with the higher level frameworks which are STANDARD place now
Im an angular monorepo developer
the support for nestJS backends is huge now
and im trying to run with nestJS in an elite fashion with the new build scaffolds
high velocity
currently shutdown
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.
Getting this issue when I run
nest g module users
any ideas?