У меня есть проект node.js, и после обновления посылки я сталкиваюсь с проблемой. Ранее посылка компилировала/объединяла код в этих 2 файлах. Однако после обновления он теперь меняет мой файл app.js. И я не могу понять, как настроить посылку в ранее обоснованные 2 файлы.
Когда я запускаю «NPX Parcel Build» ./public/js/js/index.js ---dist-dir ./public/js ---no-cache 'команда или команда «npm run watch». Эта команда изменяет мой файл app.js. < /P>
Перед выполнением команды, мой файл app.js < /p>
У меня есть проект node.js, и после обновления посылки я сталкиваюсь с проблемой. Ранее посылка компилировала/объединяла код в этих 2 файлах. Однако после обновления он теперь меняет мой файл app.js. И я не могу понять, как настроить посылку в ранее обоснованные 2 файлы.[code]{ "name": "Project", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "start": "nodemon server.js", "watch:js": "parcel watch ./public/js/index.js --dist-dir ./public/js/bundle.js", "build:js": "parcel watch ./public/js/index.js --dist-dir ./public/js/bundle.js" } "dependencies": { "@babel/polyfill": "^7.12.1", "axios": "^1.10.0" }, "devDependencies": { "parcel": "^2.15.4". } < /code> Использование Pascal-bundle, я хочу запустить этот код из файла index.js < /p> login.js file < /p> import axios from 'axios' export const login=async(email,password)=>{ try{ const res=await axios({ method:'POST', url:'http://127.0.0.1:7000/api/v1/user/login', data:{ email, password } }) if(res.data.status==='success'){ alert('Logged in Successfully!') window.setTimeout(()=>{ location.assign('/') },1500) }
}catch(err){ alert(err.response.data.message) } } console.log('the document is: ',document.querySelector('.form')) < /code> index.js file < /p> import '@babel/polyfill' import {login} from './login' document.querySelector('.form').addEventListener('submit',e=>{ e.preventDefault() const email=document.getElementById('email').value; const password=document.getElementById('password').value; login(email,password) }) [/code] Когда я запускаю «NPX Parcel Build» ./public/js/js/index.js ---dist-dir ./public/js ---no-cache 'команда или команда «npm run watch». Эта команда изменяет мой файл app.js. < /P> Перед выполнением команды, мой файл app.js < /p> [code]app.use('/',viewRoute) app.use('/api/v1/tours',tourRoute) app.use('/api/v1/user',userRoute) app.use('/api/v1/review',reviewRoute) app.all('*',(req,res,next)=>{ next(new AppError(`Can't find ${req.originalUrl} on this server!`,404))}) [/code] После запуска команды в моем файле [b] app.js [/b] он автоматически генерирует этот код [code]require("@babel/polyfill"); var $knI9B$axios = require("axios"); const $70af9284e599e604$export$596d806903d1f59e = async (email, password)=>{ try { const res = await (0, ($parcel$interopDefault($knI9B$axios)))({ method: 'POST', url: 'http://127.0.0.1:7000/api/v1/user/login', data: { email: email, password: password } }); if (res.data.status === 'success') { alert('Logged in Successfully!'); window.setTimeout(()=>{ location.assign('/'); }, 1500); } } catch (err) { alert(err.response.data.message); } }; console.log('the document is: ', document.querySelector('.form')); document.querySelector('.form').addEventListener('submit', (e)=>{ e.preventDefault(); const email = document.getElementById('email').value; const password = document.getElementById('password').value; (0, $70af9284e599e604$export$596d806903d1f59e)(email, password); });
//# sourceMappingURL=app.js.map < /code> Я хочу попытаться выполнить этот код в bundle.js и bundle.js.map. Не выполняется в app.js и не делает файл app.js.map < /p> require("@babel/polyfill"); var $knI9B$axios = require("axios"); const $70af9284e599e604$export$596d806903d1f59e = async (email, password)=>{ try { const res = await (0, ($parcel$interopDefault($knI9B$axios)))({ method: 'POST', url: 'http://127.0.0.1:7000/api/v1/user/login', data: { email: email, password: password } }); if (res.data.status === 'success') { alert('Logged in Successfully!'); window.setTimeout(()=>{ location.assign('/'); }, 1500); } } catch (err) { alert(err.response.data.message); } }; console.log('the document is: ', document.querySelector('.form')); document.querySelector('.form').addEventListener('submit', (e)=>{ e.preventDefault(); const email = document.getElementById('email').value; const password = document.getElementById('password').value; (0, $70af9284e599e604$export$596d806903d1f59e)(email, password); }); [/code] Я пробовал несколько вещей, чтобы исправить его, и постоянно получить такой же вывод. Спасибо Advance