We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I run npx parcel serve --target frontend, I get the error "Cannot read property 'env' of undefined". But watch or build works fine.
npx parcel serve --target frontend
watch
build
PS D:\Projects\_TEST\TsFullStack> npx parcel serve --target frontend Server running at http://localhost:1234 脳 Build failed. Error: Cannot read property 'env' of undefined TypeError: Cannot read property 'env' of undefined at TargetResolver.resolve (D:\Projects\_TEST\TsFullStack\node_modules\@parcel\core\lib\requests\TargetRequest.js:281:56) at async Object.run (D:\Projects\_TEST\TsFullStack\node_modules\@parcel\core\lib\requests\TargetRequest.js:145:17) at async RequestTracker.runRequest (D:\Projects\_TEST\TsFullStack\node_modules\@parcel\core\lib\RequestTracker.js:721:20) at async AssetGraphBuilder.runTargetRequest (D:\Projects\_TEST\TsFullStack\node_modules\@parcel\core\lib\requests\AssetGraphRequest.js:751:19) at async PromiseQueue._runFn (D:\Projects\_TEST\TsFullStack\node_modules\@parcel\utils\lib\PromiseQueue.js:88:7) at async PromiseQueue._next (D:\Projects\_TEST\TsFullStack\node_modules\@parcel\utils\lib\PromiseQueue.js:75:5)
Command: npx parcel serve --target frontend
Project Structure:
- dist - - ... - node_modules - - ... - packages - - backend - - - src - - - - index.ts - - common - - - src - - - - index.ts - - frontend - - - src - - - - index.html - - - - index.ts - package.json - package-lock.json - tsconfig.json
package.json
{ "name": "ts-full-stack", "version": "1.0.0", "description": "TypeScript full-stack application", "author": "chop", "dependencies": { "express": "^4.17.1" }, "devDependencies": { "@types/express": "^4.17.13", "@types/node": "^16.9.3", "concurrently": "^6.2.1", "parcel": "^2.0.0", "typescript": "^4.4.3" }, "targets": { "frontend": { "source": "packages/frontend/src/index.html", "distDir": "dist/frontend", "context": "browser", "engines": { "browsers": "> 5%, last 2 versions, not dead" }, "includeNodeModules": true }, "backend": { "source": "packages/backend/src/index.ts", "distDir": "dist/backend", "context": "node", "engines": { "node": ">= 14" }, "includeNodeModules": true } }, "scripts": { "watch:frontend": "parcel watch --target frontend", "watch:backend": "parcel watch --target backend", "build": "npm run build:backend & npm run build:frontend", "build:frontend": "parcel build --target frontend", "build:backend": "parcel build --target backend" } }
tsconfig.json
{ "compilerOptions": { "isolatedModules": true } }
index.html in frontend
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script type="module" src="index.ts"></script> </head> <body> <h2>Hello World</h2> </body> </html>
index.ts in frontend
import { sayHi } from '../../common/src/index'; console.log("Frontend Module Loaded"); sayHi("Loki"); export {};
index.ts in common
console.log("Common Module Loaded"); export function sayHi(user) { alert(`Hello, ${user}!`); }
The text was updated successfully, but these errors were encountered:
Duplicate of #6905. Will be fixed in the next release: #7187
Sorry, something went wrong.
No branches or pull requests
馃悰 bug report
When I run
npx parcel serve --target frontend
, I get the error "Cannot read property 'env' of undefined". Butwatch
orbuild
works fine.馃帥 Configuration
Command:
npx parcel serve --target frontend
Project Structure:
package.json
tsconfig.json
index.html in frontend
index.ts in frontend
index.ts in common
馃實 Your Environment
The text was updated successfully, but these errors were encountered: