嗨,我目前正在研究Next Js项目。我正在为我的项目使用Blockly软件包。当我使用npm run dev在本地运行项目时,一切正常。但是,一旦我尝试构建项目,就会收到以下错误。
./node_modules/canvas/build/Release/canvas.node 1:0
Module parse failed: Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
> Build error occurred
Error: > Build failed because of webpack errors
at build (...node_modules/next/dist/build/index.js:13:917)
at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs-semantic@1.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs-semantic@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
这是我的next.config.js文件
const withPlugins = require('next-compose-plugins');
const css = require('@zeit/next-css');
const nextConfig = {
target: 'serverless',
webpack(config) {
config.module.rules.push({
test: /\.(png|svg|jpg|eot|otf|ttf|woff|woff2|mp3)$/,
use: {
loader: 'url-loader',
options: {
limit: 8192,
publicPath: '/_next/static/',
outputPath: 'static/',
name: '[name].[ext]',
},
},
});
return config;
},
};
module.exports = withPlugins([[css]], nextConfig);
请帮助。任何帮助表示赞赏。我不需要画布包。但是我相信Blockly包正在使用jsdom包,而jsdom包又将canvas包作为依赖项。如果有一种在构建时忽略jsdom和canvas包的方法也可以。请帮助我成为所有这些的新手。