为构建我的项目做了一个修理工,但是出了点问题,我得到了这个错误:
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in /usr/app/node_modules/postcss/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:429:9)
at packageExportsResolve (node:internal/modules/esm/resolve:703:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.552 (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11590)
at __nccwpck_require__ (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11735)
at Object.270 (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:400)
at __nccwpck_require__ (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11735)
at Object.327 (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:260)
at __nccwpck_require__ (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11735)
at Object.845 (/usr/app/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:3733) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v17.4.0
Service 'nextjs' failed to build : The command '/bin/sh -c npm run build' returned a non-zero code: 1这是我的Dockerfile
FROM node:alpine
# Set working directory
WORKDIR /usr/app
# Install PM2 globally
RUN npm install --global pm2
# Copy "package.json" and "package-lock.json" before other files
# Utilise Docker cache to save re-installing dependencies if unchanged
COPY ./package*.json ./
# Install dependencies
RUN npm install --production
# Copy all files
COPY ./ ./
# Build app
RUN npm run build
# Expose the listening port
EXPOSE 3000
# Run container as non-root (unprivileged) user
# The "node" user is provided in the Node.js Alpine base image
USER node
# Launch app with PM2
CMD [ "pm2-runtime", "start", "npm", "--", "start" ]这是我的package.json:
{
"name": "nextjs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^10.0.6",
"react": "17.0.1",
"react-dom": "17.0.1"
}
}尝试删除我的node_modules文件夹并重新安装,但是它不起作用。什么使用post/css包,错误是由于节点版本造成的?如果是的话,我应该在我的Dockerfile中使用什么高寒版本?
发布于 2022-03-30 21:53:44
我想是迟到了,但我有办法。我面对的问题和你在这一行中面临的问题一样
import { useState } from "react/cjs/react.production.min";你应该试试这个..。
import {useState} from 'react' directlyhttps://stackoverflow.com/questions/70918410
复制相似问题