nexus-plugin-prisma
nexus-plugin-prisma copied to clipboard
@nexus/schema must be installed as a dependency on webpack build
Hi there. I get a below error when I try to run build by webpack.
ERROR: @nexus/schema must be installed as a dependency. Please run `npm install @nexus/schema`.
@nexus/schema
is in a package.json's dependencies.
I didn't get this error run build by tsc.
Please let me know how to build with webpack.
Duplicate of #843
Can you please show me your webpack.config? We just managed to fix it on our end.
The plugin should be part of externals along with prisma and nexus/schema. You also need to make sure it's imported correctly in your project (if externals is nexus-plugin-prisma, then importing from 'nexus-plugin-prisma/schema' will throw an error and vice-versa)
Can you please show me your webpack.config? We just managed to fix it on our end.
The plugin should be part of externals along with prisma and nexus/schema. You also need to make sure it's imported correctly in your project (if externals is nexus-plugin-prisma, then importing from 'nexus-plugin-prisma/schema' will throw an error and vice-versa)
Could you create a repo with a simplified version of your setup? I'm coming from one of the Prisma examples so I'm not using webpack, but I'm very confused how I could set up Webpack to compile my project.
I am also affected @creativiii
ERROR: nexus must be installed as a dependency. Please run `npm install nexus`.
My webpack config.
const serverlessWebpack = require('serverless-webpack');
const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
target: 'node',
devtool: 'inline-source-map',
entry: serverlessWebpack.lib.entries,
mode: serverlessWebpack.lib.webpack.isLocal ? 'development' : 'production',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
optimization: {
minimize: false,
},
plugins: [
new CopyPlugin({
patterns: [
{
from: "node_modules/.prisma/client/query-engine-rhel-openssl-1.0.x",
to: "node_modules/.prisma/client/query-engine-rhel-openssl-1.0.x"
},
],
}),
],
};
Would you consider another workaround for function ensureDepIsInstalled(depName: string)
? Webpack cannot resolve this during the build.
I came across the same:
ERROR: nexus must be installed as a dependency. Please run `npm install nexus`.
in a Rush monorepo, and traced it down to my schema file which had these imports:
import { nexusPrisma } from 'nexus-plugin-prisma';
import { makeSchema } from 'nexus';
Switching the imports around "fixed it".
Received the same error when attempting a deploy to Heroku:
remote: ERROR: nexus must be installed as a dependency. Please run `npm install nexus`.
Couldn't replicate locally.
The solution above of switching the nexus import order solved the issue - thanks @djm!
@djm I am getting the same error ?
nexus must be installed as a dependency. Please run
npm install nexus.
my imports are like this and still getting error
import { nexusPrisma } from 'nexus-plugin-prisma';
import { makeSchema } from 'nexus';
also can you tell me the exact versions of these modules?
I can't believe I forgot to post here. Turns out the problem is likely not related to nexus-plugin-prisma at all. After extensive research and trial and error I think this is caused by Prisma incorrectly not generating types.
We had an extensive talk about it prisma/prisma#5175 with some solutions.
I've also set up a simple boilerplate for Serverless Prisma projects https://github.com/coloredcat/serverless-prisma-vercel-boilerplate